S3: make a public folder private again?

前端 未结 12 2007
北恋
北恋 2021-01-30 20:16

How do you make an AWS S3 public folder private again?

I was testing out some staging data, so I made the entire folder public within a bucket. I\'d like to restrict it

12条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-30 20:19

    For AWS CLI, it is fairly straight forward.

    If the object is: s3:///file.txt

    For single object:

    aws s3api put-object-acl --acl private --bucket  --key file.txt
    

    For all objects in the bucket (bash one-liner):

    aws s3 ls --recursive s3:// | cut -d' ' -f5- | awk '{print $NF}' | while read line; do
        echo "$line"
        aws s3api put-object-acl --acl private --bucket  --key "$line"
    done
    

提交回复
热议问题