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.
Version
29.7.0
Steps to reproduce
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