Skip to content

Instantly share code, notes, and snippets.

@g-a-d
Created November 6, 2017 15:41
Show Gist options
  • Save g-a-d/4bc7f716bc57e42b64e1ef450be9bae8 to your computer and use it in GitHub Desktop.
Save g-a-d/4bc7f716bc57e42b64e1ef450be9bae8 to your computer and use it in GitHub Desktop.
Converting CloudFormation parameter files to CodePipeline Template Configuration files
Using jq, we can convert between CloudFormation parameter files and CodePipeline template configuration files:
$ jq '{ Parameters: [ .[] | { (.ParameterKey): .ParameterValue } ] | add } ' < cloudformation_parameter_file.json
This is useful in the case of receiving 'Template configuration is not valid' when running a CloudFormation action.
A CloudFormation parameter file has format:
[
{
"ParameterKey": "key1",
"ParameterValue": "value1"
},
{
"ParameterKey": "key2",
"ParameterValue": "value2"
}
]
Whereas a CodePipeline Template Configuration file has format:
{
"Parameters": {
"key1": "value1",
"key2": "value2"
}
}
@krishnanmuthukumar
Copy link

Excellent! Thanks

@Justiono
Copy link

Justiono commented Nov 29, 2023

This is great. I'd like to contribute back with the reverse conversion, in case anyone needs.
cat codepipeline_params.json | jq -r '.Parameters | to_entries | map({ParameterKey: .key, ParameterValue: .value})'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment