S3: make a public folder private again?

前端 未结 12 1886
北恋
北恋 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:18

    The accepted answer works well - seems to set ACLs recursively on a given s3 path too. However, this can also be done more easily by a third-party tool called s3cmd - we use it heavily at my company and it seems to be fairly popular within the AWS community.

    For example, suppose you had this kind of s3 bucket and dir structure: s3://mybucket.com/topleveldir/scripts/bootstrap/tmp/. Now suppose you had marked the entire scripts "directory" as public using the Amazon S3 console.

    Now to make the entire scripts "directory-tree" recursively (i.e. including subdirectories and their files) private again:

    s3cmd setacl --acl-private --recursive s3://mybucket.com/topleveldir/scripts/
    

    It's also easy to make the scripts "directory-tree" recursively public again if you want:

    s3cmd setacl --acl-public --recursive s3://mybucket.com/topleveldir/scripts/
    

    You can also choose to set the permission/ACL only on a given s3 "directory" (i.e. non-recursively) by simply omitting --recursive in the above commands.

    For s3cmd to work, you first have to provide your AWS access and secret keys to s3cmd via s3cmd --configure (see http://s3tools.org/s3cmd for more details).

提交回复
热议问题