Skip to content

feat(cloudwatch): add cross-account support for LogQueryWidget #33925

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

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

Conversation

AvinashChowdary
Copy link

Issue #26105

Closes #26105.

Reason for this change

CloudWatch dashboards support cross-account log queries, but the CDK's LogQueryWidget doesn't provide a way to specify the account ID. This change adds support for cross-account log queries in CloudWatch dashboards through the LogQueryWidget.

Description of changes

  • Added an account property to the LogQueryWidgetProps interface
  • Added logic to include the accountId property in the widget properties when an account is specified
  • Added tests to verify the functionality works correctly with single and multiple log groups

This change enables users to create CloudWatch dashboards that include log queries from different AWS accounts, which is useful for organizations with multiple accounts or those using AWS Organizations.

Describe any new or updated permissions being added

No new IAM permissions are being added in the CDK code itself. However, users will need to ensure they have the appropriate cross-account permissions set up for CloudWatch Logs queries to work correctly. This is mentioned in the JSDoc comments for the new property.

Description of how you validated changes

Added three new unit tests that verify:

  1. The accountId property is correctly included when an account is specified
  2. The accountId property is not included when no account is specified
  3. Multiple log groups work correctly with cross-account queries

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 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Mar 27, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 27, 2025 03:07
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter fails with the following errors:

❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

@aws-cdk-automation
Copy link
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. Note that PRs with failing linting check or builds are not reviewed, please ensure your build is passing

To prevent automatic closure:

  • Resume work on the PR
  • OR request an exemption by adding a comment containing 'Exemption Request' with justification e.x "Exemption Request: "
  • OR request clarification by adding a comment containing 'Clarification Request' with a question e.x "Clarification Request: "

This PR will automatically close in 14 days if no action is taken.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 60dd700
  • 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
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK 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)
2 participants