Skip to content

Commit

Permalink
fix(aws-cloudformation): Fix ParameterOverrides (#574)
Browse files Browse the repository at this point in the history
ParameterOverrides needs to be a JSON-encoded object, not an object
itself.

Fixes #566.
  • Loading branch information
rix0rrr authored Aug 15, 2018
1 parent 939015a commit 279df79
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export abstract class CloudFormationDeploymentAction extends CloudFormationActio
// This must be a string, so flatten the list to a comma-separated string.
Capabilities: (capabilities && capabilities.join(',')) || undefined,
RoleArn: new cdk.Token(() => this.role.roleArn),
ParameterOverrides: props.parameterOverrides,
ParameterOverrides: cdk.CloudFormationJSON.stringify(props.parameterOverrides),
TemplateConfiguration: props.templateConfiguration ? props.templateConfiguration.location : undefined,
StackName: props.stackName,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,45 @@ export = {

test.done();
},

'parameterOverrides are serialized as a string'(test: Test) {
// GIVEN
const stack = new TestFixture();

// WHEN
new CreateUpdateStack(stack, 'CreateUpdate', {
stage: stack.deployStage,
stackName: 'MyStack',
templatePath: stack.source.artifact.subartifact('template.yaml'),
parameterOverrides: {
RepoName: stack.repo.repositoryName
}
});

// THEN
expect(stack).to(haveResource('AWS::CodePipeline::Pipeline', {
"Stages": [
{ "Name": "Source" /* don't care about the rest */ },
{
"Name": "Deploy",
"Actions": [
{
"Configuration": {
"ParameterOverrides": { "Fn::Join": [ "", [
"{\"RepoName\":\"",
{ "Fn::GetAtt": [ "MyVeryImportantRepo11BC3EBD", "Name" ] },
"\"}"
]]}
},
"Name": "CreateUpdate",
},
],
}
]
}));

test.done();
}
};

/**
Expand Down

0 comments on commit 279df79

Please sign in to comment.