Advertisement
Javi

AWS: CLI for deleting things

Oct 28th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. buckets=$(aws s3api list-buckets --region eu-west-1 --query Buckets[].[Name] --output text)
  4. while read -r line ; do aws s3 rb s3://$line --force; done <<< "$buckets"
  5.  
  6. Alernative:
  7.  
  8. PREFIX=blog
  9.  
  10. BUCKETS=$(aws s3 ls | grep $PREFIX | awk '{print $3}')
  11. echo $BUCKETS| while read BUCK; do aws s3 rb $BUCK --force; done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement