Skip to content

Instantly share code, notes, and snippets.

@sansagara
Created July 24, 2019 17:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sansagara/4145471fc23ad5e80398896705db0683 to your computer and use it in GitHub Desktop.
Print a list of aws buckets along with their tags
#!/bin/bash
# lists all buckets along with their tags in the following format:
# bucket_name | { tag_name: tag_value }
# depends on AWS CLI and JQ
for bucket in `aws s3api list-buckets | jq .Buckets[].Name -r`; do
tags=$(aws s3api get-bucket-tagging --bucket $bucket | jq -c '.[][] | {(.Key): .Value}' | tr '\n' '\t')
echo $bucket '|' $tags
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment