Skip to content

Instantly share code, notes, and snippets.

@brianonn
Created March 12, 2023 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianonn/094eeb037662ea1b9b7c6b9cd9e80bdd to your computer and use it in GitHub Desktop.
Save brianonn/094eeb037662ea1b9b7c6b9cd9e80bdd to your computer and use it in GitHub Desktop.
describe instances in AWS with a nice table output
#!/bin/sh
## -----------------------------------------------------------------------
## | DescribeInstances |
## +-----------------+-----------------------+-------------+-------------+
## | IP Address | Instance ID | Name | State |
## +-----------------+-----------------------+-------------+-------------+
## | 10.66.122.61 | i-e947af0a891355efc | Server 002 | terminated |
## | 10.163.29.52 | i-828f336627c36ba76 | Server 001 | terminated |
## | 10.222.236.205 | i-60cef875d3e88c7a5 | Server 001 | terminated |
## | 10.127.100.68 | i-31af6f57609abfd73 | Server 002 | terminated |
## | 10.242.81.197 | i-fe947954c52a4ac48 | Server 002 | running |
## | 10.238.107.19 | i-e404601a47b082cb3 | Server 001 | running |
## +-----------------+-----------------------+-------------+-------------+
aws ec2 describe-instances \
--query '
Reservations[*].Instances[*].
{"Name": Tags[?Key=='"'Name'"'] |
[0].Value,
"Instance ID": InstanceId,
"IP Address": PrivateIpAddress,
"State" : State.Name}
' --output table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment