Created
December 22, 2017 15:38
-
-
Save overdrive3000/ea6f10cbe6b5498e1e92503c3f35f6be to your computer and use it in GitHub Desktop.
List Cloudformation Stacks by Tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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