SRE
SRE

Reputation: 111

Retrieve only one parameter value from aws ssm get-parameter command?

How can I print only the value of Value attribute from the below output of the following command

aws ssm get-parameter --name "/test/ip/cidr" --profile test
{
    "Parameter": {
        "Name": "/test/ip/cidr",
        "Type": "String",
        "Value": "172.18.0.0/20",
        "Version": 1,
        "LastModifiedDate": 1585251360.78,
        "ARN": "arn:aws:ssm:us-east-1:123233:parameter/test/ip/cidr",
        "DataType": "text"
    }
}

Tried running the below command but prints like [{"Value": "172.18.0.0/20"}] but just want to see only 172.18.0.0/20

aws ssm get-parameters --names "/test/ip/cidr" --query "Parameters[*].{Value:Value}" --profile test
[
    {
        "Value": "172.18.0.0/20"
    }
]

Upvotes: 8

Views: 10285

Answers (1)

Marcin
Marcin

Reputation: 238209

You can add --output text and modify your --query:

aws ssm get-parameter --name "/test/ip/cidr" --profile test \
  --query "Parameter.Value" --output text 

Upvotes: 29

Related Questions