I am very new to jq, I am trying to parse an output json I get from command -
aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE
to get a new output where values of the key matches to certain pattern.
for example this is my json output from previous command -
{
"StackSummaries": [
{
"StackId": "arn:aws:213dqwqwdqwdqwdq",
"StackName": "monkeyman",
"CreationTime": "2017-06-06T20:52:59.728Z",
"StackStatus": "CREATE_COMPLETE",
"TemplateDescription": "Liaison API ELB cloud formation script"
},
{
"StackId": "arn:aws:csdfsdfcsdfsdfsdfsdfsdfgdfgfdg",
"StackName": "monkeyman2",
"CreationTime": "2017-06-06T20:51:55.191Z",
"StackStatus": "CREATE_COMPLETE",
"TemplateDescription": "yoohooo instance"
},
{
"StackId": "arn:aws:sdffgds444fsdfsdfgdfgfdg",
"StackName": "starfish2",
"CreationTime": "2017-06-06T20:51:55.191Z",
"StackStatus": "CREATE_COMPLETE",
"TemplateDescription": "helloworld instance"
},
{
"StackId": "arn:aws:csdfsdfcsdfsdfsdfsdfsdfgdfgfdg",
"StackName": "bulldog4",
"CreationTime": "2017-06-06T20:51:55.191Z",
"StackStatus": "CREATE_COMPLETE",
"TemplateDescription": "night night instance"
},
{
"StackId": "arn:aws:yhyhyhyhyhysdfgdfgfdg",
"StackName": "carrotman",
"CreationTime": "2017-06-06T20:51:55.191Z",
"StackStatus": "CREATE_COMPLETE",
"TemplateDescription": "surprise mo instance"
}
]
}
Here I need to create a new output json by piping the first output to jq where StackName startsWith monkeyman and bulldog and which should look like -
{
"StackSummaries": [
{
"StackId": "arn:aws:213dqwqwdqwdqwdq",
"StackName": "monkeyman",
"CreationTime": "2017-06-06T20:52:59.728Z",
"StackStatus": "CREATE_COMPLETE",
"TemplateDescription": "Liaison API ELB cloud formation script"
},
{
"StackId": "arn:aws:csdfsdfcsdfsdfsdfsdfsdfgdfgfdg",
"StackName": "monkeyman2",
"CreationTime": "2017-06-06T20:51:55.191Z",
"StackStatus": "CREATE_COMPLETE",
"TemplateDescription": "yoohooo instance"
},
{
"StackId": "arn:aws:csdfsdfcsdfsdfsdfsdfsdfgdfgfdg",
"StackName": "bulldog4",
"CreationTime": "2017-06-06T20:51:55.191Z",
"StackStatus": "CREATE_COMPLETE",
"TemplateDescription": "night night instance"
}
]
}
I have tried a lot, I was able to do it somehow using basic unix split and regex commands but something tells me it would be easier and less cumbersome to do directly with jq.