From c6e915379ed59e8556b0579921f75a12a554320e Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Wed, 15 Aug 2018 13:13:38 +0200 Subject: [PATCH] fix(aws-cloudformation): Fix ParameterOverrides ParameterOverrides needs to be a JSON-encoded object, not an object itself. Fixes #566. --- .../lib/pipeline-actions.ts | 2 +- .../test.cloudformation-pipeline-actions.ts | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-cloudformation/lib/pipeline-actions.ts b/packages/@aws-cdk/aws-cloudformation/lib/pipeline-actions.ts index ccf019dfaba0e..7a7106063bdef 100644 --- a/packages/@aws-cdk/aws-cloudformation/lib/pipeline-actions.ts +++ b/packages/@aws-cdk/aws-cloudformation/lib/pipeline-actions.ts @@ -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, }); diff --git a/packages/@aws-cdk/aws-codepipeline/test/test.cloudformation-pipeline-actions.ts b/packages/@aws-cdk/aws-codepipeline/test/test.cloudformation-pipeline-actions.ts index 31af69b00e18b..4a28eff000bc0 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/test.cloudformation-pipeline-actions.ts +++ b/packages/@aws-cdk/aws-codepipeline/test/test.cloudformation-pipeline-actions.ts @@ -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(); + } }; /**