Created
June 25, 2019 20:59
-
-
Save jaypipes/66f8e740a66d5cd43fc40f27c676baa4 to your computer and use it in GitHub Desktop.
Grab instance ID, name, public and private IP address for EC2 instances into array of JSON objects
This file contains hidden or 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
#!/usr/bin/env bash | |
aws ec2 describe-instances \ | |
| jq '.Reservations[].Instances[] | { id: .InstanceId, name: .Tags[] | select(.Key == "Name").Value, publicip: .PublicIpAddress, privateip: .PrivateIpAddress }'\ | |
| jq -s 'sort_by(.name)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output looks like the following: