Created
November 6, 2017 15:41
-
-
Save g-a-d/4bc7f716bc57e42b64e1ef450be9bae8 to your computer and use it in GitHub Desktop.
Converting CloudFormation parameter files to CodePipeline Template Configuration files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} | |
} | |
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
Excellent! Thanks