Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

return text list of values one line per instance-id with awscli --query

I have instances in AWS that have the same ReservationId (they were launched at the same time and they have AmiLaunchIndex of 0 thru x ). My goal is to produce text output with one line per instance, such as this. I added column headers for clarity.

OwnerId      ReservationId InstanceId  PrivateIpAddress AmiLaunchIndex
12345678910  r-poiu4567    i-asdf1234  10.0.0.1         0
12345678910  r-poiu4567    i-qwer4312  10.0.1.1         1
... etc ...

In the jmespath gitter channel, the map function was suggested as a way to accomplish this, but I can't figure out how to use the function. Any suggestions?

like image 810
LHWizard Avatar asked Oct 20 '25 21:10

LHWizard


1 Answers

--query Reservations[*].Instances[*].[InstanceId] --output text

Just add the brakets

like image 107
martin Avatar answered Oct 25 '25 20:10

martin