Last active
December 21, 2015 22:19
-
-
Save aegrumet/6374367 to your computer and use it in GitHub Desktop.
AWS command-line jq commands
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
# ec2 instance info | |
aws ec2 describe-instances | sed -e 's/"Key"/"key"/' -e 's/"Value"/"value"/' |jq -c '[.Reservations[].Instances[]|{PrivateIpAddress,PublicIpAddress, AZ: .Placement.AvailabilityZone, Name: (.Tags|from_entries|.Name)}]|sort_by(.Name)[]' | |
# ec2 instance info with filter | |
aws --profile us ec2 describe-instances --filters '[{"Name":"tag-key","Values":["Name"]}, {"Name":"tag-value","Values":["*agentserver*"]}]' | sed -e 's/"Key"/"key"/' -e 's/"Value"/"value"/' |jq -c '[.Reservations[].Instances[]|{PrivateIpAddress,PublicIpAddress, AZ: .Placement.AvailabilityZone, Name: (.Tags|from_entries|.Name)}]|sort_by(.Name)[]' | |
# ebs snapshot info | |
snapName="mysnapshot"; aws ec2 describe-snapshots --filter '{"name":"tag-key","values":"Name"}' --filter "{\"name\":\"tag-value\",\"values\":\"$snapName\"}" | jq -c '[.Snapshots[]|{VolumeId, SnapshotId, Description, StartTime}]|sort_by(.StartTime)[]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment