Last active
July 9, 2019 00:07
-
-
Save aschober/3924cb5e20b258e290a558f52e01063f to your computer and use it in GitHub Desktop.
Recursive AWS CLI S3 put-object-legal-hold Command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# command using s3 and s3api to recursively go through each file in a bucket and update the legal hold flag | |
# https://docs.aws.amazon.com/cli/latest/reference/s3api/put-object-legal-hold.html | |
# https://stackoverflow.com/a/53696774 | |
aws s3 ls s3://<bucket-location> --recursive > files.txt && cat files.txt | awk '{cmd="aws s3api put-object-legal-hold --legal-hold Status=OFF --bucket <bucket-location> --key "$4;system(cmd)}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment