fix(cloudwatch): cloudwatch ec2 alarm action with multiple dimension results in error#29364
fix(cloudwatch): cloudwatch ec2 alarm action with multiple dimension results in error#29364mergify[bot] merged 2 commits intomainfrom
Conversation
|
Exemption Request: No integration test needed as this changes is a bug fix and only affect when we raise exception. |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
| // Check per-instance metric | ||
| const metricConfig = this.metric.toMetricConfig(); | ||
| if (metricConfig.metricStat?.dimensions?.length != 1 || metricConfig.metricStat?.dimensions![0].name != 'InstanceId') { | ||
| if (metricConfig.metricStat?.dimensions?.length != 1 || !metricConfig.metricStat?.dimensions?.some(dimension => dimension.name === 'InstanceId')) { |
There was a problem hiding this comment.
I've just stumbled upon this PR and I think that there should be && operator instead of ||. We want to throw the exception when there are multiple dimensions AND none of them is InstanceId. Is that right?
Issue # (if applicable)
Closes #29331
Reason for this change
While trying to create a Custom Metric with multiple dimension, and adding EC2 action, the CDK synth fails.
Description of changes
As long as there's instance id in dimension, we should accept it instead of raising exception.
Description of how you validated changes
new tests and existing tests pass.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license