Created
April 22, 2015 18:46
-
-
Save filipenf/0528d26f0dba78b72b39 to your computer and use it in GitHub Desktop.
Print a list of aws buckets along with their tags
I know this is old.. But you don't need jq
for the bucket list step. Also added some additional stuff to answer other questions.
for bucket in `aws s3api list-buckets --query "Buckets[].Name" --output text` ; do
echo $bucket
tags=$(aws s3api get-bucket-tagging --bucket $bucket 2>/dev/null| jq -cr '.[][] | {(.Key): .Value}')
output=${tags:-"no Tags assigned"}
echo $output
done
~
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
update the above line and it will give you clear output
echo $bucket '|' $tags >> buckets-tags.txt