Parsing JSON parameters stored in AWS Parameter Store using jq
source link: https://alexanderzeitler.com/articles/parsing-json-parameters-stored-in-aws-parameter-store-using-jq/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Alexander Zeitler
Parsing JSON parameters stored in AWS Parameter Store using jq
The other day I had the idea to store some JSON as a AWS Parameter Store value.
If you read the parameter using AWS CLI:
aws ssm get-parameters --name /prod/some-json-param
you get something like this:
{
"Parameters": [
{
"Name": "/prod/some-json-param",
"Type": "String",
"Value": "{\n \"server\": \"\",\n \"token\": \"\"\n}",
"Version": 2,
"LastModifiedDate": 1578353153.788,
"ARN": "arn:aws:ssm:eu-central-1:1234567890:parameter/prod/some-json-param"
}
],
"InvalidParameters": []
}
What I wanted to get in a shell script, was the JSON representation of Value
like this:
{
"server": "",
"token": ""
}
Thanks to the popular jq command, this is quite easy:
aws ssm get-parameters --name /prod/some-json-param | jq '.Parameters | .[] | .Value'
That way, we get the value of Value
as a string:
"{\n \"server\": \"\",\n \"token\": \"\"\n}"
Another call to jq
will give us the desired result:
aws ssm get-parameters --name /prod/some-json-param | jq '.Parameters | .[] | .Value' | jq '.|fromjson'
{
"server": "",
"token": ""
}
Happy Coding!
Recommend
-
8
Can PowerShell Parameters Belong To Multiple Parameter Sets? Say you’ve got a function that takes three parameters: Username, ComputerName and SessionName, but you don’t want someone to use ComputerName and SessionName a...
-
19
Optional parameters, default parameter values and method overloading yourbasic.org/golang
-
5
How do I get a parameter from other parameters of the same constructors (java) advertisements So I was supposed to identify a parameter based...
-
5
Dynamic parameters in a stored procedure? advertisements I need to update a table with values from a listbox. I am trying to create as many pa...
-
61
Sookriti Mishra September 30, 2021 5 minute read
-
4
Stored Procedure OUT Parameters in PostgreSQL 14PostgreSQL global development group generally announces a new release every year, with several new features. With an increase in...
-
7
Calling Stored Procedures With IN and OUT Parameters From Spring Data JPA ...
-
3
Output paramet...
-
2
Passing Output Parameters to Stored Procedures with Dapper in C# Posted by Code Maze | Feb 23,...
-
6
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK