Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParameterOverrides string can fail CloudFormation character limit #5749

Closed
lukehedger opened this issue Jan 10, 2020 · 6 comments
Closed

ParameterOverrides string can fail CloudFormation character limit #5749

lukehedger opened this issue Jan 10, 2020 · 6 comments
Assignees
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline bug This issue is a bug.

Comments

@lukehedger
Copy link
Contributor

It is possible to generate a CloudFormation template with a value in the CodePipeline.Stages.Actions.Configuration.ParameterOverrides field that violates the maximum character limit.

Reproduction Steps

new CloudFormationCreateUpdateStackAction({
  parameterOverrides: {
    test: "somethingOver1000Characters..."
  }
});

Error Log

Pipeline (PipelineXYZ) 1 validation error detected: Value at 'pipeline.stages.4.member.actions.1.member.configuration' failed to satisfy constraint: Map value must satisfy constraint: [Member must have length less than or equal to 1000, Member must have length greater than or equal to 1]

Environment

  • CLI Version : aws-cli/1.16.130 Python/3.7.4 Darwin/18.7.0 botocore/1.12.120
  • Framework Version: 1.20
  • OS : macOS
  • Language : TypeScript

Other

As a possible solution, it seems the JSON to string transformation performed here could be adapted to make us of the Fn::Join function.

Looking at the tests it would suggest this is already being done but I have not been able to generate a CFN template that uses Fn::Join as asserted here.


This is 🐛 Bug Report

@lukehedger lukehedger added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 10, 2020
@skinny85
Copy link
Contributor

skinny85 commented Jan 10, 2020

Hey @lukehedger ,

thanks for opening the issue. Couple of follow-up questions:

  1. I'm not sure what the original ask is. Do you want us to perform this validation sooner, so that it fails at CDK build time, instead of deployment time?
  2. To force the use of Fn::Join, you can pass a Token inside the parameters; for example, similar like the test does:
new cpactions.CloudFormationCreateUpdateStackAction({
    // ...
    parameterOverrides: {
      RepoName: new codecommit.Repository(this, 'Repo', {
        repositroyName: 'repo'
      }).repositoryName,
    },
  }));

But I'm pretty sure using Fn::Join would not get you around the 1000 character limit.

Thanks,
Adam

@lukehedger
Copy link
Contributor Author

lukehedger commented Jan 13, 2020

Hey @skinny85 - thanks for the message. The ask is primarily how do I change the generation of the parameterOverrides value to stop throwing this error.

I am using the parameterOverrides to provide the dynamic S3 location of Lambda code (for 4 Lambdas) at the pipeline's runtime, as described in this example:

parameterOverrides: {
  ...props.lambdaCode.assign(lambdaBuildOutput.s3Location),
}

The output looks something like this:

"ParameterOverrides": "{\"LambdaSourceBucketNameParameter00000000\":{\"Fn::GetArtifactAtt\":[\"LambdaBuildOutput\",\"BucketName\"]},\"LambdaSourceObjectKeyParameter00000001\":{\"Fn::GetArtifactAtt\":[\"LambdaBuildOutput\",\"ObjectKey\"]}

How would I pass a Token here to force use of Fn::Join?

Or is the only way to actually get around the 1000 character limit to shorten the keys or split up the Lambdas across multiple stacks?

@SomayaB SomayaB added the @aws-cdk/aws-codepipeline Related to AWS CodePipeline label Jan 13, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Jan 13, 2020
@skinny85
Copy link
Contributor

Or is the only way to actually get around the 1000 character limit to shorten the keys or split up the Lambdas across multiple stacks?

Yes. I'm 99% certain using Fn::Join would not change anything here.

I think the solution you're looking for is this: #1588 (comment)

@lukehedger
Copy link
Contributor Author

Okay thanks @skinny85 I will use this solution. Thanks for your help!

@skinny85
Copy link
Contributor

No problem, let me know if that fixes your issue!

@lukehedger
Copy link
Contributor Author

All fixed, thanks @skinny85!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants