Categories
Snippets

jq stuff

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.

Leave a Reply

Your email address will not be published. Required fields are marked *