fledgling
fledgling

Reputation: 1051

Convert aws cli JSON output

The below aws cli command returns the following

aws cloudformation describe-stacks --stack-name home-automation-service --region us-east-1 --query "Stacks[0].Outputs[*].{OutputKey:OutputKey,OutputValue:OutputValue}"  --output json


[
    {
        "OutputKey": "URLPath",
        "OutputValue": "https://home-automation-service.jakeworld.com"
    },
    {
        "OutputKey": "Port",
        "OutputValue": "8080"
    }    
]

I want to convert the json to resemble the following

    {
        "URLPath": "https://home-automation-service.jakeworld.com",
        "Port": "8080"
    }

Can this be done using the --query parameter in the aws cli? If not, appreciate help using any other way of doing it?

Upvotes: 0

Views: 445

Answers (1)

peak
peak

Reputation: 116720

A jq solution:

map( {(.OutputKey) : .OutputValue} ) | add

Upvotes: 1

Related Questions