Skip to content

Instantly share code, notes, and snippets.

@jsamuel1
Forked from filipenf/aws-s3-buckets-with-tags.sh
Last active February 25, 2019 04:36
Show Gist options
  • Save jsamuel1/4e47f296788c6b37095155e93cf9af4e to your computer and use it in GitHub Desktop.
Save jsamuel1/4e47f296788c6b37095155e93cf9af4e 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 }
for bucket in `aws s3api list-buckets | jq .Buckets[].Name -r`; do
tags=$(aws s3api get-bucket-tagging --bucket $bucket 2>/dev/null | 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