Last active
December 10, 2018 04:44
-
-
Save porjo/ed0d7dacea7fbd28c5acab157d400759 to your computer and use it in GitHub Desktop.
Dump AWS EC2 instances to tab delimited output
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
#!/bin/bash | |
echo -e "Name\tInstanceID\tInstanceType\tState\tLaunchTime\tAvailabilityZone\tPrivateIP\tPublicIP" | |
#aws ec2 describe-instances --output text --query 'Reservations[*].Instances[*].[[Tags[?Key==`Name`].Value] [0][0], InstanceId, InstanceType, State.Name, LaunchTime, Placement.AvailabilityZone, PrivateIpAddress, PublicIpAddress ]' | |
aws ec2 describe-instances > instances.json | |
cat instances.json | jq -r '.Reservations[].Instances[]| [(.Tags[] | select(.Key == "Name") | .Value), .InstanceId, .InstanceType, .State.Name, .LaunchTime, .Placement.AvailabilityZone, .PrivateIpAddress, .PublicIpAddress, .VpcId ] | @tsv' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment