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

[Bug]: Snapshot Test Fails After Setting Multiple CloudWatch Alarms to the Same Lambda (AWS CDK v2.136.0 or Later) #15376

Open
mickey-DWS opened this issue Nov 13, 2024 · 0 comments

Comments

@mickey-DWS
Copy link

mickey-DWS commented Nov 13, 2024

Version

29.7.0

Steps to reproduce

  1. Use AWS CDK version v2.136.0 or later.
  2. Create multiple CloudWatch alarms and attach them to the same Lambda function as shown in the code snippet above.
  3. Run Jest snapshot tests for the CloudFormation stack or Lambda configuration.
  4. 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.

Image

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant