• Home
  • Health
  • Software
  • Blog
  • cli-commands

    Set All S3 Bucket Files to Public/Private


    # Set all to private:
    AWS_PROFILE=test aws s3api list-objects --bucket bucketname --query 'Contents[].{Key: Key}' --output text | while read key; do AWS_PROFILE=test aws s3api put-object-acl --bucket bucketname --key $key --acl private; done
    
    # Set all to public:
    AWS_PROFILE=test aws s3api list-objects --bucket bucketname --query 'Contents[].{Key: Key}' --output text | while read key; do AWS_PROFILE=test aws s3api put-object-acl --bucket bucketname --key $key --acl public-read; done