aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.93k forks source link

feat(cloudwatch): add `accountId` property to support Cross-Account visibility for Logs and Metric Widgets #31512

Open sumupitchayan opened 1 month ago

sumupitchayan commented 1 month ago

Closes #26105

Reason for this change

Support cross-account visibility on Metric and Log Widget Objects by allowing customers to specify the AWS Account ID that the data (logs or metrics) originates from. For more information, see Cross-Account Cross-Region CloudWatch Console.

CloudWatch docs shows that accountId is supported in CloudFormation for Logs Widget Objects and Metric Widget Objects.

Description of changes

Added an optional accountId property to LogQueryWidgetProps and MetricWidgetProps. This allows you to set an Account ID on LogQueryWidget and the four different metric widgets:

  1. AlarmWidget
  2. GaugeWidget
  3. GraphWidget
  4. SingleValueWidget

Description of how you validated changes

Unit Tests

In graph.test.ts, I added the accountId property to existing tests on each of the five Widget types mentioned above, validating that they appear in the synthesized stack.

Integ Tests

Same as above, I added accountId property to existing integ tests (integ.math-alarm-and-dashboard.ts and integ.alarm-and-dashboard.ts) on each of the five Widget types, updated the snapshots and successfully deployed the integ tests.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

aws-cdk-automation commented 1 month ago

AWS CodeBuild CI Report

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