Skip to content
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

Merged
merged 2 commits into from
Mar 14, 2024

Conversation

GavinZZ
Copy link
Contributor

@GavinZZ GavinZZ commented Mar 6, 2024

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

@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p1 labels Mar 6, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team March 6, 2024 00:49
@GavinZZ GavinZZ added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Mar 6, 2024
@GavinZZ
Copy link
Contributor Author

GavinZZ commented Mar 6, 2024

Exemption Request: No integration test needed as this changes is a bug fix and only affect when we raise exception.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Mar 6, 2024
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 6, 2024
@GavinZZ GavinZZ marked this pull request as ready for review March 6, 2024 01:18
Copy link
Contributor

mergify bot commented Mar 14, 2024

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: cb62ec8
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit cc37778 into main Mar 14, 2024
12 checks passed
@mergify mergify bot deleted the yuanhaoz/ec2_alarm branch March 14, 2024 23:13
Copy link
Contributor

mergify bot commented Mar 14, 2024

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')) {
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p1 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cloudwatch: Use of EC2 action with Multiple dimension set in metric results into error
4 participants