make all files private using aws-shell for S3

142 Views Asked by At

I want to change the files of a bucket (all files) to private, so i'm wondering how to do it with aws-shell. I think that maybe the mv command can be useful to achieve this, but i cant figure out how to use it, because this is the first time that i use aws-shell.

Edit 1

I tried using s3 mv s3://bucket s3://temporary --recursive --acl private, but i needed to create another temporary bucket to make the swap. Because of this error:

Cannot mv a file onto itself [...]

Is there a way to do this without creating a temporary bucket? I mean that this could cause charges for having transactions and space being used by duplicate files

1

There are 1 best solutions below

0
John Rotenstein On

You can copy the files onto themselves and change the Access Control List.

Test it out, but it would be something like:

aws s3 cp s3://bucket s3://bucket --recursive --acl private

Keep the source and destination the same.