I am trying to filter through tags of this JSON output (http://pastebin.com/RjjBH7g4JSON output)
Selecting through the Tags[] and display the selected values if the key exist.
My jq filter looks like this :
jq -r ".Reservations[]
| [.OwnerId,
.Instances[].InstanceId,
.Instances[].Placement.AvailabilityZone,
(.Instances[].Tags[]?|select(.Key==OtherTag)|.Value),
(.Instances[].Tags[]?|select(.Key==Name)|.Value) ]
| @csv"
The output looks like this
"xxxxxxxxxx9,i-d414ce0b,ap-southeast-2b,webserver2"
I would like it to include the unfounded select tags and fill it in as empty field in the csv like below :
"xxxxxxxxxx9,i-d414ce0b,ap-southeast-2b,,webserver2"
What should I do in jq to achieve that? Can someone give me an example?