Reputation: 1
I would like to ask a question in line with above. The cli below works perfectly fine now I would also like to capture two other tags in addition to the 'Name' tag called 'Application' and 'Owner'. How can I change this to add Application and Owner tags to the out-put. So basically:
aws ec2 describe-instances --query "Reservations[].Instances[].[Placement.AvailabilityZone,InstanceId,InstanceType,Platform, State.Name,PrivateIpAddress,StateTransitionReason,Tags[?Key=='Name'] | [0].Value]" --output table
What I am thinking is how do I duplicate Tags[?Key=='Name'] | [0].Value]
to make it also pull Application and Owner so in effect Tags[?Key=='Application'] | [0].Value]
and Tags[?Key=='Owner'] | [0].Value]
? So that when I run the cli it pulls three different tags.
Upvotes: 0
Views: 3710
Reputation: 717
Fetching Custom tags are really helpful when you try to build something on top of that, like- system or Application configuration based on those, for EaaS, DEaaS, or TEaaS.
Hope this will work for you :
aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,InstanceType,Platform,State.Name,PrivateIpAddress,StateTransitionReason,Tags[?Key==Application
].Value | [0], Tags[?Key==Name
].Value | [0],Tags[?Key==Owner
].Value | [0]]' --output table –
Upvotes: 0
Reputation: 1
this works also. (those are back ticks around the key value)
--query 'Snapshots[*].{DES:Description,VOL:VolumeId,VSIZE:VolumeSize,Time:StartTime,ID:SnapshotId,Name:Tags[?Key==Name
]|[0].Value,RP:Tags[?Key==retention-period
]|[0].Value}'
Upvotes: 0
Reputation: 269340
Just add it on...
--query "Reservations[].Instances[].[InstanceId,Tags[?Key=='Name']|[0].Value,Tags[?Key=='Application']|[0].Value,Tags[?Key=='Owner']|[0].Value]"
Upvotes: 1