Skip to content

Instantly share code, notes, and snippets.

@overdrive3000
Created December 22, 2017 15:38
Show Gist options
  • Save overdrive3000/ea6f10cbe6b5498e1e92503c3f35f6be to your computer and use it in GitHub Desktop.
Save overdrive3000/ea6f10cbe6b5498e1e92503c3f35f6be to your computer and use it in GitHub Desktop.
List Cloudformation Stacks by Tag
#!/bin/bash
usage(){
echo "Usage: $0 -k <Key> -v <Value>"
echo "Sample: $0 -k Name -v MyStack"
echo "Note: Key and Value are case sensitive"
exit 1
}
while getopts k:v: option
do
case "${option}"
in
k) KEY=${OPTARG};;
v) VALUE=${OPTARG};;
*) usage;;
esac
done
aws cloudformation describe-stacks --query 'Stacks[?Tags[?Value==`'${VALUE}'` && Key==`'${KEY}'`]].{Name:StackName,Status:StackStatus,CreationTime:CreationTime}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment