AWS Certified Solutions Architect – Associate
S3 access control: bucket policies, Block Public Access, ACLs
New S3 buckets have ACLs disabled and no public access, so access is decided by policies: IAM policies and bucket policies. Block Public Access overrides any policy or ACL that would make a bucket or object public. A presigned URL gives time-limited access using the permissions of whoever created it.
Block Public Access
There are four settings. BlockPublicAcls rejects requests that set a public ACL, including PutObject with a public ACL. IgnorePublicAcls makes S3 ignore public ACLs on the bucket and its objects. BlockPublicPolicy rejects PutBucketPolicy when the new policy allows public access. RestrictPublicBuckets limits a bucket with a public policy to AWS service principals and users in the bucket owner's account, which also blocks cross-account access.
The settings can be applied at the organization, account, bucket and access point level, and S3 applies the most restrictive combination. AWS recommends BlockPublicPolicy at the account level, because a user who can edit a bucket policy could otherwise turn the bucket's own setting off.
None of the settings change existing policies or ACLs. Turning a setting off makes a bucket with a public policy or ACL public again.
An ACL is public if it grants anything to the AllUsers or AuthenticatedUsers groups. A bucket policy is non-public only if it grants access to fixed values, such as specific principals or accounts, aws:SourceVpce, or a fixed aws:SourceIp range. A policy that names a partner account is not public.
Object Ownership and ACLs
Object Ownership has three settings. Bucket owner enforced is the default for new buckets: ACLs are disabled, the bucket owner owns every object, and only policies decide access. Bucket owner preferred keeps ACLs, and the bucket owner owns new objects uploaded with the bucket-owner-full-control canned ACL. Object writer keeps ACLs, and the uploading account owns the object.
With ACLs disabled, the bucket accepts only PUT requests that set no ACL or set bucket-owner-full-control. Any other ACL fails with HTTP 400 and the error code AccessControlListNotSupported. Other accounts get access through the bucket policy. AWS recommends keeping ACLs disabled unless you must control access per object.
Presigned URLs
A presigned URL lets someone without AWS credentials download or upload a specific object until it expires. It uses the credentials of the IAM principal that created it. Anyone with credentials can create one, but it only works if the creator has permission for the operation, such as s3:PutObject for an upload.
Expiry is capped. The S3 console allows 1 minute to 12 hours. The CLI and SDKs allow up to 7 days, which requires IAM user credentials and Signature Version 4. A URL made with temporary credentials expires when those credentials expire. For an EC2 instance role that is typically about 6 hours, whatever expiry you asked for.
S3 checks the expiry when the request starts, and the URL can be used more than once until then. A bucket policy can use s3:signatureAge to reject URLs whose signature is older than a limit you set.
Where the exam catches people
- Believing Block Public Access removes public grants that already exist: it overrides them without changing them, so turning it off makes them public again.
- Believing
BlockPublicAclsrejects every upload that carries an ACL: it rejects public ACLs, and it is Bucket owner enforced that rejects other ACLs. - Believing a presigned URL lasts as long as you ask: it cannot outlive the credentials that signed it.
- Believing a read-only user can create a working upload URL: the creator needs permission for the operation the URL performs.
- Believing a bucket policy that grants a named partner account is public: grants to fixed principals are non-public.