Categories
Snippets

jq makes AWS “describe-instances” actually useful

Just so I don’t forget 🙂 aws ec2 describe-instances | \ jq ‘.Reservations[].Instances[] | {IP: .PrivateIpAddress, ID: .InstanceId, Name: .Tags[] | select(.Key==”Name”).Value}’  

Categories
Snippets

Ansible inventory file from Consul

Quick self-reminder: curl consul.domain:8500/v1/catalog/nodes | jq ‘.[]|.Address’ | tr -d ‘”‘

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 […]