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

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

sumupitchayan
Copy link
Contributor

@sumupitchayan sumupitchayan commented Sep 20, 2024

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

… prop in LogQueryWidget and the 4 Metrics Widgets (AlarmWidget, GaugeWidget, GraphWidget, and SingleValueSidget )

Signed-off-by: Sumu <sumughan@amazon.com>
… prop in LogQueryWidget and the 4 Metrics Widgets (AlarmWidget, GaugeWidget, GraphWidget, and SingleValueSidget )cd

Signed-off-by: Sumu <sumughan@amazon.com>
…tests for each Widget type

Signed-off-by: Sumu <sumughan@amazon.com>
Signed-off-by: Sumu <sumughan@amazon.com>
Signed-off-by: Sumu <sumughan@amazon.com>
(integ.alarm-and-dashboard.ts)

Signed-off-by: Sumu <sumughan@amazon.com>
@aws-cdk-automation aws-cdk-automation requested a review from a team September 20, 2024 17:34
@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1 labels Sep 20, 2024
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Sep 20, 2024
Signed-off-by: Sumu <sumughan@amazon.com>
Signed-off-by: Sumu <sumughan@amazon.com>
@sumupitchayan sumupitchayan changed the title feat(cloudwatch): add accountId property to support Cross-Account/Cross-region with Logs and Metric Widgets feat(cloudwatch): add accountId property to support Cross-Account with Logs and Metric Widgets Sep 20, 2024
@sumupitchayan sumupitchayan changed the title feat(cloudwatch): add accountId property to support Cross-Account with Logs and Metric Widgets feat(cloudwatch): add accountId property to support Cross-Account visibility for Logs and Metric Widgets Sep 20, 2024
@sumupitchayan sumupitchayan marked this pull request as ready for review September 20, 2024 19:12
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 20, 2024
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sumupitchayan i've got a couple of questions before i give my approval

@@ -61,6 +61,8 @@ dashboard.addWidgets(new cloudwatch.SingleValueWidget({
}));
dashboard.addWidgets(new cloudwatch.LogQueryWidget({
title: 'Errors in my log group',
// Setting an account ID just for this LogQueryWidget
accountId: '123456789',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have specific accountIds that won't get flagged by security. is this one of them? also, account ids are 12 numbers long

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's good to know - I just put in a random number here, will update it 👍

*
* @default - None
*/
readonly accountId?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the default really none? or is the default that the accountid is the same as the account doing the cfn deploy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout - the property is not required, but it uses the current account by default (docs)

I'll update the comment

}));

dashboard.addWidgets(new cloudwatch.GraphWidget({
title: 'Percentage of messages in each queue as pie chart',
left: [metricA, metricB],
view: cloudwatch.GraphWidgetView.PIE,
setPeriodToTimeRange: true,
accountId: '123456789',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are any of these integ tests passing if this isn't a real account?

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 30, 2024
Signed-off-by: Sumu <sumughan@amazon.com>
@sumupitchayan sumupitchayan self-assigned this Sep 30, 2024
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Cloudwatch LogQueryWidgetProps): (Lack of accountId filed)
3 participants