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
(aws-lambda): specifying insightsVersion generates invalid CloudFormation #18789
Comments
I tested with both the TypeScript and Go CDK SDKs. |
I receive the same error, my lambda insights cdk code: |
Thanks for the report, @wolverian. This looks like a bug. Looks like the mapping was altered in this commit: https://github.com/aws/aws-cdk/pull/17984/files#diff-7d58dae78817493ec1119dc627f2ca5412971a0a6baea5a7c90fe69912e29fd6. Since this is a deploy time error, I'd wager that this was an oversight, and has never worked since. @rix0rrr what shall we do here? I think at a minimum we need to update this:
since We also do some stuff that is specific to insights version here:
All these replacements with |
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](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 #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*
|
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*
What is the problem?
If I specify
insightsVersion
as so:I get this error:
Reproduction Steps
https://github.com/wolverian/cdk-lambda-insights-issue/blob/main/lib/cdk-lambda-insights-issue-stack.ts#L18
This repo should reproduce the issue.
What did you expect to happen?
The generated CloudFormation is valid.
What actually happened?
The generated CloudFormation uses invalid keys in the
Mapping
section:CDK CLI Version
2.10.0 (build e5b301f)
Framework Version
No response
Node.js Version
v16.13.2
OS
macOS Monterey 12.2 (21D49)
Language
Typescript, Go
Language Version
TypeScript 3.9.7 | go version go1.18beta1 darwin/arm64
Other information
No response
The text was updated successfully, but these errors were encountered: