Fly, Penguin!

I blog so I don't forget.

jq stuff

0 minute read #tools: jq #tools #cli

Waah. 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.