Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
    }
]
like image 781
SRE Avatar asked Jun 04 '26 07:06

SRE


1 Answers

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

aws ssm get-parameter --name "/test/ip/cidr" --profile test \
  --query "Parameter.Value" --output text 
like image 194
Marcin Avatar answered Jun 07 '26 23:06

Marcin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!