Home > Software design >  S3 default public ACL fot object
S3 default public ACL fot object

Time:04-01

Is there any ways to upload/update object in s3 with defaults public-read ACL?

I know that we have f.e

aws s3 cp /path/to/file s3://sample_bucket --acl public-read

but here we can specify only one obj, and actualy it is does not work if I'll upload same file again

CodePudding user response:

From Bucket policy examples - Amazon Simple Storage Service:

The following example policy grants the s3:GetObject permission to any public anonymous users. This permission allows anyone to read the object data, which is useful for when you configure your bucket as a website and want everyone to be able to read objects in the bucket. Before you use a bucket policy to grant read-only permission to an anonymous user, you must disable block public access settings for your bucket.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::BUCKET-NAME/*"
            ]
        }
    ]
}

Note that this is a Bucket Policy that is added to the Bucket, not the IAM User.

In your comments above, you provided this policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "S3:*",
            ],
            "Sid": "",
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::bucket/*"
        }
    ]
}

This policy does not have a Principal, which makes me think that you were attempting to add it to an IAM User rather than a Bucket.

  • Related