donnemartin / saws

A supercharged AWS command line interface (CLI).
Other
5.23k stars 280 forks source link

saws is great, but how to list the IP address with tag value of "*prod*" #95

Closed ozbillwang closed 8 years ago

ozbillwang commented 8 years ago

I have several ec2 instances with tag as:

 # format is APP[Number]-ENV, such as lb01-stag, web02-prod, etc.
 Name: lb01-prod 

So I like to list all production instances IP address only, how to prepare the command? Output should be Name and IP.

 aws ec2 ls --ec2-tag-value ...   ???
donnemartin commented 8 years ago

Hi @SydOps, thanks for the feedback.

You can pipe the output to another command such as grep:

saws> aws ec2 ls --ec2-tag-key TAGKEY | grep 'PublicIp\|PrivateIpAddress\|InstanceId'
                    "InstanceId": "i-FOOOBARR",
                    "PrivateIpAddress": "w.x.y.z",
                            "PrivateIpAddress": "w.x.y.z",