Cloud

Creating Fine-Grained S3 Access Controls with AWS Policies

Fine-grained S3 access control is built by combining IAM policies, resource policies, and condition keys. The goal is simple: each identity can access only the exact bucket path and actions it needs.

Design principles

  • Least privilege by default
  • Scope permissions to specific bucket prefixes
  • Use explicit denies for high-risk actions when needed
  • Separate human/admin access from app/service roles

Example: allow read/write to one prefix only

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket"],
      "Resource": "arn:aws:s3:::my-company-data",
      "Condition": {
        "StringLike": {
          "s3:prefix": ["team-a/*"]
        }
      }
    },
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
      "Resource": "arn:aws:s3:::my-company-data/team-a/*"
    }
  ]
}

Common controls to add

  • Require encryption at upload (s3:x-amz-server-side-encryption)
  • Restrict access by VPC endpoint or source IP (where appropriate)
  • Block public ACL/policy paths via account and bucket settings
  • Enforce MFA for sensitive admin operations

Bucket policy example: deny non-TLS requests

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": [
        "arn:aws:s3:::my-company-data",
        "arn:aws:s3:::my-company-data/*"
      ],
      "Condition": {
        "Bool": {"aws:SecureTransport": "false"}
      }
    }
  ]
}

Validation workflow

  • Test with IAM Policy Simulator
  • Verify app role behavior in dev before prod
  • Review CloudTrail for AccessDenied and unexpected allows
  • Use Access Analyzer for policy risk insights

Operational tips

  • Version-control policy JSON
  • Use naming conventions for role-to-prefix mapping
  • Review permissions periodically as data paths evolve

This approach gives strong S3 isolation and predictable access behavior for teams and applications.

Operational Checklist (Production-Safe)

  • Confirm prerequisites and permissions before changes.
  • Apply the change in staging or a low-risk window first.
  • Validate identity, network path, and policy scope before promoting changes to production.
  • Document rollback steps and owner responsibility.
  • Re-verify service health and security controls after completion.

Validation and Success Criteria

  • The target workflow completes without errors and without introducing service interruption.
  • Expected security/availability behavior is confirmed through logs and direct functional tests.
  • No unintended access, policy drift, or performance regression is observed after deployment.

Common Pitfalls to Avoid

  • Applying changes without confirming exact environment prerequisites.
  • Skipping post-change verification and relying only on command success output.
  • Not defining rollback steps before touching production assets.

References