AWS S3 - ACL vs. CORS configuration vs. bucket/object permissions
Asked Answered
F

1

12

It seems that Access Control Lists (ACL), CORS configurations, and the permissions for each bucket and object all come into play when configuring the access settings for S3 buckets/objects.

Can someone explain the difference between these and how they work together?

Fraya answered 22/9, 2016 at 4:0 Comment(2)
S3 documentation: docs.aws.amazon.com/AmazonS3/latest/dev/S3_ACLs_UsingACLs.htmlLymphoma
Yes I have been reading the docs. I was just looking for a succinct description of how each method is different from the others, as I haven't found this in the docs.Fraya
P
6

S3 Bucket policies

They are the recommended way to configure access of a S3 bucket. A policy is a JSON document composed of statements. In each statement you either Allow or Deny an action to a Principal (the users affected by the policy).

Access control lists

Considered legacy, they predate the implementation of bucket policies but they allow to set permission at a file level. For example if you want to restrict the access for a specific file within a bucket, but not the whole bucket, you will need to use ACLs.

CORS Configuration

This a XML file to configure the CORS headers. You can choose to only allow http some methods (for example GET and POST) or all of them.

More details in the AWS Documentation.

For more info about CORS: What is CORS?.

IAM Policies

They are similar to Bucket policies, except you attach them an User, Group or Role, except of a bucket.

Conflicts

In case of conflict between ACL/IAM policies/Bucket policies, for example if there both Allow and Deny applying to the same resource and user, the Deny always win.

The algorithm to resolve permission is basically: - If there is a Deny, Deny access - If there is an Allow, Allow access - If there isn't anything, Deny by default

Best practices

Apply the principle of least privilege (don't allow access unless it's needed). It's not recommended to attach policies directly to an User, but rather to create a group with the permission attached to it, then add the user to the group. You can have for example a group Developer with full access on S3, a group Finance with read-only access. If you need to restrict access to a bucket, use bucket policies. Only use ACL if you need to configure access to individual files.

Proser answered 27/4, 2019 at 11:54 Comment(1)
Can you use a bucket policy and then apply ACL on an item by item basis to create exceptions?Plasticity

© 2022 - 2024 — McMap. All rights reserved.