aws_cdk.aws_cloudwatch: CfnAlarm drops MetricDataQueryProperty contents if arguments come from a dict #27372
Labels
@aws-cdk/aws-cloudwatch
Related to Amazon CloudWatch
closed-for-staleness
This issue was automatically closed because it hadn't received any attention in a while.
response-requested
Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Describe the bug
When instantiatig a CfnAlarm from a Dict as follows:
It will fail with the following error from the Stack:
Resource handler returned message: "Period must not be null (Service: CloudWatch, Status Code: 400, Request ID: 123)"
Expected Behavior
The Alarm should be created successfully and the stack should not fail.
Current Behavior
When checking the synth output in
cdk.out
I see the following was generated:The second object in
abcde.Properties.Metrics
with"id": "m1"
is missing all properties.Reproduction Steps
See provided code.
Possible Solution
Instantiating the
MetricDataQueryProperty
manually like so:Will generate the expected, correct CF code in
cdk.out
. This is not great because we load the CF from a file and would like to not parse it any further if possible.Additional Information/Context
When checking the
CfnAlarmProps
spec: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_cloudwatch/CfnAlarmProps.htmlI would interpret the type for
metrics
(Union[IResolvable, Sequence[Union[IResolvable, MetricDataQueryProperty, Dict[str, Any]]], None]
) to allow for Dicts. Maybe I just misinterpeted that?CDK CLI Version
2.99.1 (build b2a895e)
Framework Version
No response
Node.js Version
18.16.0
OS
Ubuntu 20.04.6 LTS (in WSL on Win 11)
Language
Python
Language Version
Python 3.11
Other information
No response
The text was updated successfully, but these errors were encountered: