Monday, 5 June 2017

aws cli Command To list Instances With Particular Tag

Command To list AWS Instances With Particular Tag

AWS CLI Command To List Instance Having Particular Tag


AWS CLI provides to list instances on the basis of various filters and you can get specific details about the instances based on those filters. If you haven't setup aws-cli, here is a tutorial to install and configure aws-cli.
Below is the command to list only instance-id of all the instances having a Tag "Monitor" with value "True".

aws ec2 describe-instances --filters Name=tag:Monitor,Values=True --query 
'Reservations[].Instances[].[InstanceId]' --output text

Here we are only listing the Instance-Id, But you may also list other information like Private IP address as shown below:

aws ec2 describe-instances --filters Name=tag:Monitor,Values=True --query 
'Reservations[].Instances[].[InstanceId,PrivateIpAddress]' --output text

We have also specified output to be in text format, which will display two columnar data, one column for InstanceId and other for PrivateIpAddress. If you don't want columnar type output want the output then just remove the "--output text" from the command:


aws ec2 describe-instances --filters Name=tag:Monitor,Values=True --query 
'Reservations[].Instances[].[InstanceId,PrivateIpAddress]'

0 comments:

Post a Comment

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel