-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Conversation
@@ -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)); |
There was a problem hiding this comment.
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).
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). |
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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*
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 atcdk synth
that would fail atcdk deploy
. One such example is the mappings generated forlambda-insights
in #18789.In this PR, the replacement value is updated from
_
tox
. 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