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

‼️ (aws-cloudwatch): cross account alarms cause failures in unsupported regions #16874

Closed
eladb opened this issue Oct 8, 2021 · 1 comment · Fixed by #16875
Closed

‼️ (aws-cloudwatch): cross account alarms cause failures in unsupported regions #16874

eladb opened this issue Oct 8, 2021 · 1 comment · Fixed by #16875
Assignees
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p0

Comments

@eladb
Copy link
Contributor

eladb commented Oct 8, 2021

Workaround is available 👇

What is the problem?

When deploying an @aws-cdk/aws-cloudwatch.Alarm in regions with no support for cross-account alarms, the deployment fails with the following error:

Encountered unsupported property AccountId

This is because the change in #16007 always adds an AccountId to metrics.

Reproduction Steps

Define a CDK stack with an AWS CloudWatch Alarm and deploy it to a region that still does not have support for cross-account alarms.

What did you expect to happen?

Success

What actually happened?

Encountered unsupported property AccountId

CDK CLI Version

1.126.0

Framework Version

1.126.0

Node.js Version

N/A

OS

N/A

Language

Typescript, Python, .NET, Java, Go

Language Version

N/A

Other information

Ref: P53531109

Workaround

You can delete the AccountId property by locating the CfnResource behind the cloudwatch.Alarm construct and then calling addPropertyDeletionOverride.

Consider the following example:

const alarm = new cloudwatch.Alarm(this, 'Alarm', {
  threshold: 1,
  evaluationPeriods: 1,
  metric: new cloudwatch.Metric({
    label: 'MyMetric',
    account: this.account,
    namespace: 'AWS/DynamoDB',
    metricName: 'ReadThrottleEvents',
    dimensionsMap: {
      TableName: 'MyTable'
    },
    statistic: 'Sum'
  }),
});

This is how the AWS::CloudWatch::Alarm is synthesized:

Alarm7103F465:
    Type: AWS::CloudWatch::Alarm
    Properties:
      ComparisonOperator: GreaterThanOrEqualToThreshold
      EvaluationPeriods: 1
      Metrics:
        - AccountId: "123456789012"
          Id: m1
          Label: MyMetric
          MetricStat:
            Metric:
              Dimensions:
                - Name: TableName
                  Value: MyTable
              MetricName: ReadThrottleEvents
              Namespace: AWS/DynamoDB
            Period: 300
            Stat: Sum
          ReturnData: true
      Threshold: 1

The following code will delete the AccountId property from the metric at index 0 (Metrics.0) in the alarm:

const cfnAlarm = alarm.node.defaultChild as CfnResource;
cfnAlarm?.addPropertyDeletionOverride('Metrics.0.AccountId');
@eladb eladb added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 8, 2021
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label Oct 8, 2021
@eladb eladb added the p0 label Oct 8, 2021
@eladb eladb pinned this issue Oct 8, 2021
@eladb eladb changed the title (aws-cloudwatch): cross account alarms cause failures in unsupported regions ❗❗(aws-cloudwatch): cross account alarms cause failures in unsupported regions Oct 8, 2021
@eladb eladb changed the title ❗❗(aws-cloudwatch): cross account alarms cause failures in unsupported regions ‼️ (aws-cloudwatch): cross account alarms cause failures in unsupported regions Oct 8, 2021
@mergify mergify bot closed this as completed in #16875 Oct 8, 2021
mergify bot pushed a commit that referenced this issue Oct 8, 2021
…pport cross-account alarms (#16875)

Fixes #16874

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Oct 8, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@eladb eladb unpinned this issue Oct 11, 2021
njlynch pushed a commit that referenced this issue Oct 11, 2021
…pport cross-account alarms (#16875)

Fixes #16874

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
…pport cross-account alarms (aws#16875)

Fixes aws#16874

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants