π Why Access Control Matters in Amazon S3
Amazon S3 stores sensitive data β so controlling who can access what is critical. AWS offers three main access control mechanisms you need to know for the SysOps exam:
- Bucket Policies
- IAM Policies
- Access Control Lists (ACLs)
Each method serves different purposes, with different levels of granularity and scope.
π 1οΈβ£ Bucket Policies
Bucket Policies are JSON documents attached to an S3 bucket that define what actions are allowed or denied for which users, services, or accounts.
- Applied at the bucket level
- Supports resource-based permissions
- Often used for public access, cross-account access, or service-specific permissions
Example: Allow public read access to a bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}
Pros:
- Centralized, easy to manage
- Can grant cross-account access
- Resource-based (attached to the bucket)
Common exam use case:
β
Make a bucket public
β
Grant another AWS account access to a bucket
π 2οΈβ£ IAM Policies
IAM Policies are attached to IAM users, groups, or roles. They define what actions a principal (user, group, or role) can perform on which AWS resources.
- Applied at the identity level
- Cannot make a bucket public (only allows authenticated users in your account)
Example: Grant full access to a bucket for a specific IAM role
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::my-bucket",
"arn:aws:s3:::my-bucket/*"
]
}
]
}
Pros:
- Managed centrally in IAM
- Can be attached to roles, users, and groups
- Great for internal access control within your account
Common exam use case:
β
Allow an EC2 instance (using an IAM role) to upload files to S3
π 3οΈβ£ Access Control Lists (ACLs)
S3 ACLs are the legacy access control method.
- Applied to individual objects and buckets
- Defines permissions for specific AWS accounts, groups, or the public
- Limited to READ, WRITE, READ_ACP, WRITE_ACP actions
Example: Grant public read access to a specific object
aws s3api put-object-acl --bucket my-bucket --key myfile.txt --acl public-read
Pros:
- Simple, good for object-level control
- Useful for legacy apps
Cons:
- Limited flexibility
- AWS recommends using policies over ACLs
Common exam use case:
β
Temporarily grant public read access to a specific object
β
Share a file with another AWS account
π Comparison: Bucket Policies vs IAM Policies vs ACLs
Feature | Bucket Policy | IAM Policy | ACL |
---|---|---|---|
Applied To | Buckets | IAM users, groups, roles | Buckets & Objects |
Controls | Who can access the bucket & what actions | What actions IAM users/roles/groups can perform | Who can access objects/buckets |
Public Access | β Yes | β No | β Yes |
Cross-account Access | β Yes | β No | β Yes |
Granularity | Bucket-level | User-level | Object-level |
Best Practice | β Recommended | β Recommended | β Legacy, limited use |
β Common SOA-C02 Exam Scenarios
π Scenario 1:
Make a bucket public
β Use a Bucket Policy
π Scenario 2:
Allow an EC2 instance to upload to an S3 bucket
β Use an IAM Role with an IAM Policy
π Scenario 3:
Allow a different AWS account to write to a bucket
β Use a Bucket Policy with cross-account permissions
π Scenario 4:
Temporarily grant public read access to a specific file
β Use an Object ACL
π S3 Block Public Access (Important!)
Even if Bucket Policies or ACLs allow public access, Block Public Access settings can override them to prevent accidental exposure.
- Can be set at account or bucket level
- Recommended to leave Block Public Access ON by default and only selectively disable
Exam Tip:
β
If public access isnβt working, check Block Public Access settings
β Summary
Feature | Description |
---|---|
Bucket Policy | Resource-based access control at bucket level |
IAM Policy | Identity-based access control for IAM users, groups, roles |
ACL | Legacy object/bucket-level access permissions |
Block Public Access | Global/public access override setting |
Best Practice:
β
Use IAM Policies + Bucket Policies for access management
β Avoid ACLs where possible
β
Always configure Block Public Access appropriately