Skip to content

Instantly share code, notes, and snippets.

@cm-watanabeseigo
Last active September 5, 2018 09:54
Show Gist options
  • Save cm-watanabeseigo/524e56ee0296520cbba6cf30a89fca2b to your computer and use it in GitHub Desktop.
Save cm-watanabeseigo/524e56ee0296520cbba6cf30a89fca2b to your computer and use it in GitHub Desktop.
#!/bin/bash
(
echo "InstanceId,Name,Status,PublicIP,PrivateIP,InstanceType,AvailabilityZone,LaunchTime"
aws ec2 describe-instances | \
jq -r '.[][].Instances[] | [.InstanceId,
[.Tags[] | select(.Key == "Name").Value][],
.State.Name, .PublicIpAddress,
.PrivateIpAddress,
.InstanceType,
.Placement.AvailabilityZone,
.LaunchTime] |@csv' | \
sed -e 's/,,/,-,/g' -e 's/"//g'
) | column -s, -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment