2

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"
    }
]
SRE
  • 41
  • 2
  • 7
  • I've noticed that you have lots of questions with answers, yet only one answer was ever accepted. If all other answers were not helpful, then at least a comment why they fail to address the issue is a good practice. Accepting good answers not only reduces duplicates but it also makes your questions more likely to be answered. – Marcin Jul 12 '21 at 02:59
  • Thanks for your suggestion. I will do that. – SRE Jul 12 '21 at 12:02

1 Answers1

11

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

aws ssm get-parameter --name "/test/ip/cidr" --profile test \
  --query "Parameter.Value" --output text 
Dunedan
  • 7,848
  • 6
  • 42
  • 52
Marcin
  • 215,873
  • 14
  • 235
  • 294