-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
-
I'm submitting a ...
- πͺ² bug report
- [ x ] π feature request
- π construct library gap
- βοΈ security issue or vulnerability => Please see policy
- β support request => Please see note at the top of this template.
-
What is the current behavior?
When creating a new Metric for a CloudWatch dashboard, an 'undefined' is accepted for the dimensions value, but CloudFormation will reject it. -
What is the expected behavior (or behavior of feature suggested)?
CDK should evaluate the name/value of a dimension and reject invalid values. -
What is the motivation / use case for changing the behavior or adding this feature?
Input validation at the CDK build process is better than waiting for CloudFormation. -
Please tell us about your environment:
- CDK CLI Version: 0.35.0
- Module Version: 0.35.0
- OS: [all ]
- Language: [TypeScript]
-
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
const dashboard = new cloudwatch.Dashboard(this, name, { dashboardName: name});
const newMetric = new Metric({
dimensions: {
AutoScalingGroupName: undefined,
},
metricName: "CPUUtilization",
namespace: "AWS/EC2",
statistic: "avg",
});
dashboard.addWidgets(
new GraphWidget({
left: [
newMetric,
],
title: `Average CPU`,
}),
);
}
The above will build. But the following error is given from CloudFormation
The dashboard body is invalid, there are 1 validation errors: [ { "dataPath": "/widgets/0/properties/metrics/0", "message": "Should NOT have more than 3 items" } ] (Service: AmazonCloudWatch; Status Code: 400; Error Code: InvalidParameterInput;