jq stuff
Posted on December 11, 2015 (Last modified on March 9, 2022) • 1 min read • 60 wordsWaah. In case I *ever* need this again.
aws ec2 describe-security-groups | \
jq '.SecurityGroups | \
map(select(has("Tags"))) | \
map(select(.Tags[].Key|contains("Name"))) | \
.[] | \
[ .Tags , .GroupId ] | \
[ (.[0]|map(select(.Key=="Name")))[0].Value, .[1] ] | \
join("=") '
What does it do? It makes a list
$NAME_TAG=$GROUP_ID
… for each security group which has a name tag. Yeah, right.