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

fix(core): undeployable due to invalid mapping #18922

Merged
merged 3 commits into from Feb 11, 2022
Merged

Conversation

kaizencc
Copy link
Contributor

In #17984, mappings were altered so that non-alphanumeric values were replaced with _. However, the names in the name-value pairs must be fully alphanumeric according to the docs. The result was potentially invalid mappings generated at cdk synth that would fail at cdk deploy. One such example is the mappings generated for lambda-insights in #18789.

In this PR, the replacement value is updated from _ to x. The mapping is not surfaced anywhere other than the template, so we just need a value that satisfies cloudformation. Thus we're okay with the slight loss of readability. In addition, CfnMapping is updated to validate the names in the name-value pair and ensure that it is alphanumeric.

Fixes #18789.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Feb 10, 2022

@github-actions github-actions bot added the @aws-cdk/core Related to core CDK functionality label Feb 10, 2022
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 10, 2022
@@ -108,4 +110,16 @@ export class CfnMapping extends CfnRefElement {
}
this.lazyInformed = true;
}

private validateMapping(mapping: Mapping): Mapping {
Object.keys(mapping).forEach((m) => Object.keys(mapping[m]).forEach(this.validateAlphanumeric));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this matters other than for testing but -- the complexity of this function looks to be O(nm). Can't think of a better way to do it but I'm curious if this is prohibitive (I feel like its ok).

@mergify
Copy link
Contributor

mergify bot commented Feb 11, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit db28485 into master Feb 11, 2022
@mergify mergify bot deleted the conroy/mapping1 branch February 11, 2022 15:51
@mergify
Copy link
Contributor

mergify bot commented Feb 11, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: f4ffe62
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
In aws#17984, mappings were altered so that non-alphanumeric values were replaced with `_`. However, the names in the name-value pairs must be fully alphanumeric according to the [docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html). The result was potentially invalid mappings generated at `cdk synth` that would fail at `cdk deploy`. One such example is the mappings generated for `lambda-insights` in aws#18789.

In this PR, the replacement value is updated from `_` to `x`. The mapping is not surfaced anywhere other than the template, so we just need a value that satisfies cloudformation. Thus we're okay with the slight loss of readability. In addition, `CfnMapping` is updated to validate the names in the name-value pair and ensure that it is alphanumeric.

Fixes aws#18789.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-lambda): specifying insightsVersion generates invalid CloudFormation
3 participants