[Bug]: Snapshot Test Fails After Setting Multiple CloudWatch Alarms to the Same Lambda (AWS CDK v2.136.0 or Later) #15376
Open
Description
opened on Nov 13, 2024
Version
29.7.0
Steps to reproduce
- Use AWS CDK version v2.136.0 or later.
- Create multiple CloudWatch alarms and attach them to the same Lambda function as shown in the code snippet above.
- Run Jest snapshot tests for the CloudFormation stack or Lambda configuration.
- Observe that the snapshot test fails with the error:
There is already a Construct with name 'AlarmPermission' in NodejsFunction [<LambdaFunctionName>]
.
Expected behavior
I expect the snapshot tests to pass when multiple CloudWatch alarms are attached to the same Lambda function, as AWS CDK v2.136.0 or later now allows this configuration without errors during deployment.
Actual behavior
The snapshot tests fail with the following error message:
There is already a Construct with name 'AlarmPermission' in NodejsFunction [EmailContentFormatter]
Additional context
Even though the deployment works correctly and the Lambda function is successfully attached to multiple CloudWatch alarms, Jest's snapshot mechanism does not seem to handle this updated behavior properly.
Environment
System:
OS: macOS 15.0.1
CPU: (8) arm64 Apple M2
Binaries:
Node: 18.18.2 - ~/.volta/tools/image/node/18.18.2/bin/node
Yarn: 4.2.2 - ~/.volta/tools/image/yarn/4.2.2/bin/yarn
npm: 9.8.1 - ~/.volta/tools/image/node/18.18.2/bin/npm
pnpm: 8.10.0 - ~/.volta/bin/pnpm
npmPackages:
jest: ^29.7.0 => 29.7.0
Activity