Menucha Kaniel
Menucha Kaniel

Reputation: 51

Amazon S3 changing object permissions retroactively

I have a current S3 bucket with existing files.

The bucket was originally a public bucket, I changed its permissions to be private, but I already have objects that were uploaded and have public read CannedACL permissions.

How do I change the permissions on all of the uploaded objects to private CannedACL?

Upvotes: 2

Views: 1854

Answers (2)

Menucha Kaniel
Menucha Kaniel

Reputation: 51

aws s3 cp s3://my-bucket/ s3://my-bucket/ --metadata x-amz-meta-updated=1 --recursive --acl private

Upvotes: 3

John Rotenstein
John Rotenstein

Reputation: 269490

You can use the AWS Command-Line Interface (CLI) to change the permissions in-bulk.

You will use the aws s3 cp command. While this is a copy command, it can also be used to copy files in place, which simply changes their permissions.

For example:

aws s3 cp s3://my-bucket/ s3://my-bucket/ --recursive --acl bucket-owner-full-control

(bucket-owner-full-control: Both the object owner and the bucket owner get FULL_CONTROL over the object.)

See also: Amazon S3 File Permissions, Access Denied when copied from another account

Upvotes: 2

Related Questions