-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(cloudwatch): cloudwatch ec2 alarm action with multiple dimension results in error #29364
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). |
@@ -267,7 +267,7 @@ export class Alarm extends AlarmBase { | |||
if (ec2ActionsRegexp.test(actionArn)) { | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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