Created
May 4, 2016 22:06
-
-
Save seren/eb80611aeec2898a0e44e243f80a832b to your computer and use it in GitHub Desktop.
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
[{ | |
"name": "wik.is", | |
"id": 561968, | |
"address": { | |
"city": "new york", | |
"state": "NY" | |
} | |
},{ | |
"name": "bob.com", | |
"id": 50000, | |
"address": { | |
"city": "austin", | |
"state": "TX" | |
} | |
}] | |
# Get the id of bob.com | |
jq '.[] | select(.name=="bob.com") | .id' | |
# Get the id and state of bob.com | |
jq '.[] | select(.name=="bob.com") | {id, state: .address.state}' | |
-------------------------- | |
{ | |
"Computers": [ | |
{ | |
"Name": "Bob-box", | |
"Tags": [ | |
{ | |
"Name": "owner", | |
"Value": "bob" | |
}, | |
{ | |
"Name": "backup", | |
"Value": "true" | |
} | |
] | |
}, | |
{ | |
"Name": "Fred-box", | |
"Tags": [ | |
{ | |
"Name": "owner", | |
"Value": "fred" | |
}, | |
{ | |
"Name": "backup", | |
"Value": "false" | |
} | |
] | |
} | |
] | |
} | |
# Get the computer names that have the backup tag set to true | |
cat computers.json | jq '.Computers[] | select (.Tags[] | .Name == "backup" and .Value == "true") | .Name' | |
------------------ | |
# Get the cms instances from EC2 | |
aws ec2 describe-instances | jq '[.Reservations[] | .Instances[] | select( .Tags[] | .Key == "server_type" and .Value == "cms") | {InstanceId, PrivateIpAddress, PublicIpAddress, PublicDnsName}]' | |
------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment