Aws-cdk: Impossible to generate correct parameter overrides

Created on 14 Aug 2018  路  1Comment  路  Source: aws/aws-cdk

(TIL enter creates the issue! - actual issue incoming)

When creating a code pipeline with a CloudFormation action - we have a handy prop called paramterOverrides which takes { [name: string]: any };. Customers would use this to feed parameter configuration to a CloudFormation action when not using a template configuration file.

The correct configuration for this value is a JSON object (string):

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/continuous-delivery-codepipeline-action-reference.html

(Shamelessly stolen from this example: https://github.com/quarryman/AWSfrontendCI/blob/2dab0c0e4424258f9c5864885d5dfc6498dd080b/serverless-pipeline.yaml#L217 )

Configuration: 
                ActionMode: CHANGE_SET_REPLACE
                Capabilities: CAPABILITY_IAM
                ChangeSetName: !Sub '${ServiceName}-ChangeSet-Beta'
                ParameterOverrides: "{ \"SourceBucket\" : { \"Fn::GetArtifactAtt\" : [\"BetaBuiltZip\", \"BucketName\"]}, \"SourceArtifact\" : { \"Fn::GetArtifactAtt\" : [\"BetaBuiltZip\", \"ObjectKey\"]} }"
                RoleArn: !GetAtt CloudFormationExecutionRole.Arn
                StackName: !Sub '${ServiceName}-Stack-Beta'
                TemplatePath: !Sub 'BetaBuiltZip::app-output_sam.yaml'

However, we generate an object:

ParameterOverrides:
  CodeBuildBucket: {"Fn::GetArtifactAtt":["BuildOutput","BucketName"]}
  CodeBuildKey: {"Fn::GetArtifactAtt":["BuildOutput","ObjectKey"]}

I believe we just need to call JSON.stringify() the passed values.

Most helpful comment

@rix0rrr is actually working on a nifty utility function in #518 (CloudFormationJson.stringify) which can be used exactly for that purpose

>All comments

@rix0rrr is actually working on a nifty utility function in #518 (CloudFormationJson.stringify) which can be used exactly for that purpose

Was this page helpful?
0 / 5 - 0 ratings