ChatGPT解决这个技术问题 Extra ChatGPT

Make a bucket public in Amazon S3

How can I set a bucket in Amazon S3 so all the files are publicly read-only by default?

I'm annoyed this question was flagged as off topic. AWS is critical for serious programmers. I would add u can use cli sync command with acl argument like this: aws s3 sync ./local-folder-name s3://remote-bucket-name --acl=public-read
This answer to a similar post may help: stackoverflow.com/a/23102551/475882

A
Akash Kumar Verma

You can set a bucket policy as detailed in this blog post:

http://ariejan.net/2010/12/24/public-readable-amazon-s3-bucket-policy/

As per @robbyt's suggestion, create a bucket policy with the following JSON:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AllowPublicRead",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::bucket/*"
            ]
        }
    ]
}

Important: replace bucket in the Resource line with the name of your bucket.


When using official AWS CLI arn:aws:s3:::bucket also needs to be added to the Resource array. (So without the /*.) I hope this helps others who were struggling with this like me.
My bad. This is needed only if you plan to sync, not just view the bucket.
To support anonymous access through python's boto, in addition to setting this policy, I also had to grant List privilege to Everyone in the Properties > Permissions section of the bucket.
what is the rule of writeing Version? I am using current date 2017-11-16, it reports:Error: The policy must contain a valid version string
@Timothy.Li did you remember to wrap it in quotes? "2017-11-16",
c
craft

Amazon provides a policy generator tool:

https://awspolicygen.s3.amazonaws.com/policygen.html

After that, you can enter the policy requirements for the bucket on the AWS console:

https://console.aws.amazon.com/s3/home


this is official document of <<Using Bucket Policies and User Policies>> docs.aws.amazon.com/AmazonS3/latest/dev/using-iam-policies.html
Great link. Syntax is so complex they had to write a generator for it.