nojohnny101
nojohnny101

Reputation: 562

CloudFormation syntax for ParameterOverrides

I'm getting stuck on overriding multiple parameters within a CloudFormation that is passing them to CodePipeline.

I can successful override a single parameter like this:

ParameterOverrides: "{ \"StageName\": \"stage\" }"

But when I try this:

ParameterOverrides: '{ "StageName": "prod", "EnvValue", "prod" }'

I have also tried these combinations:

ParameterOverrides: "{\"StageName\": \"prod\", \"EnvValue\", \"prod\"}"

Codepipeline throws an error of: ParameterOverrides property is not valid

I have looked at this help article a half a dozen times and it seems I'm following the format to the T. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/continuous-delivery-codepipeline-parameter-override-functions.html

What am I missing? Does anyone have this working in a CloudFormation template?

Upvotes: 1

Views: 4252

Answers (2)

Kyle Laker
Kyle Laker

Reputation: 86

When dealing with embedded JSON in your YAML, the folded (>) or literal (|) block style, rather than a quoted string, will increase clarity. So something like:

ParameterOverrides: >
  {
    "StageName": "prod",
    "EnvValue": "prod"
  }

This will let you see the actual JSON without quite as much noise from the backslash escapes in the way. This can be seen in the "Example Create Stack B Stage" section of the page you linked to (it uses the literal block style with |). The difference between | and > can be seen on the YAML Multiline site.

Upvotes: 4

nojohnny101
nojohnny101

Reputation: 562

I found out what the problem was, fat fingered. I put this:

ParameterOverrides: "{\"StageName\": \"prod\", \"EnvValue\", \"prod\"}"

and it should have been this:

ParameterOverrides: "{\"StageName\": \"prod\", \"EnvValue\": \"prod\"}"

NOTICE: the missing colon on after the second key.

Upvotes: 1

Related Questions