I'm able to get the instance id, instance type, and public ip address into a table format. But I'm unable to parse the Tags Name. We plug in names for all of our servers to make them easier to identify.
Here's an example of what I've come up with so far
aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,InstanceType,PublicIpAddress]' --output table
------------------------------------------------
| DescribeInstances |
+------------+-------------+-------------------+
| i-64629700| m1.small | 54.227.243.165 |
| i-2d300249| m3.xlarge | 23.23.166.230 |
| i-7422c909| m1.small | 23.21.105.175 |
| i-08c76e24| m3.xlarge | 54.235.253.163 |
| i-99a20a72| m3.medium | 23.23.184.200 |
| i-6053991b| m1.large | 54.221.250.189 |
Not sure how I would add something like this into the table
'Reservations[].Instances[].Tags[?Key==`Name`].Value[]'
You can see the hostname values for an existing EC2 instance in the Details tab for the EC2 instance: Hostname type: The hostname in IP name or resource name format. Private IP DNS name (IPv4 only): The IP name that will always resolve to the private IPv4 address of the instance.
Open the Amazon Connect console at https://console.aws.amazon.com/connect/ . On the instances page, the instance name appears in the Instance Alias column. This instance name appears in the URL you use to access Amazon Connect.
An Amazon EC2 instance is a virtual server in Amazon's Elastic Compute Cloud (EC2) for running applications on the Amazon Web Services (AWS) infrastructure.
You're very close. Try this:
aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,InstanceType,PublicIpAddress,Tags[?Key==`Name`]| [0].Value]' --output table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With