Skip to content

Instantly share code, notes, and snippets.

@kthallam
Created September 27, 2019 08:57
Show Gist options
  • Save kthallam/aac30489c5830336ff6fa2e986140cc3 to your computer and use it in GitHub Desktop.
Save kthallam/aac30489c5830336ff6fa2e986140cc3 to your computer and use it in GitHub Desktop.
Find the List of S3 buckets does not have a specific tag value.
# Modify <Key/Value that need be searched> that you want to search
#!/bin/bash
declare -a test
test=(`aws s3 ls | awk -F ' ' '{print $3}'`)
i=0
while [ $i -lt ${#test[@]} ]
do
a=`aws s3api get-bucket-tagging --bucket ${test[$i]}| grep -w <Key/Value that need be searched> 2>/dev/null`
if [ -z "$a" ]
then
echo "${test[$i]} does not have tag "
fi
i=`expr $i + 1`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment