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"
}
}
@adamcousins
Copy link

works perfectly, thanks you saved me many hours of debugging!

@JonasMazza
Copy link

Thank you so very much! Saved me from a potential mental breakdown! Haha

@decmaxn
Copy link

decmaxn commented Jun 19, 2019

Thank you so very much! Saved me too.

@axolx
Copy link

axolx commented Dec 4, 2019

Amazing. Thank you!

@Lasim
Copy link

Lasim commented Jan 12, 2020

Thank you!

@Konosh93
Copy link

Thank you! I almost quit my job over this. :)

@dzmitry-kankalovich
Copy link

I really hate Amazon for this...

@rogerwelin
Copy link

saved me at least an hour of troubleshooting and painfully digging through aws terrible docs. Thank you!

@mwardbopp
Copy link

amazing work, thanks

@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