Skip to content

Fix: add ARN support in log_group_names for aws_cloudwatch_query_definition #43183

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

Merged
merged 5 commits into from
Jul 1, 2025

Conversation

robsonpiere
Copy link
Contributor

@robsonpiere robsonpiere commented Jun 25, 2025

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

N/A

Description

This pull request enhances the aws_cloudwatch_query_definition resource by adding support for specifying log group ARNs in addition to log group names. It also introduces a new acceptance test to validate this functionality.

Enhancements to aws_cloudwatch_query_definition resource:

  • Updated the log_group_names schema to allow validation of both log group names and ARNs using validation.Any. This ensures compatibility with ARNs while maintaining support for log group names. (internal/service/logs/query_definition.go, internal/service/logs/query_definition.goL55-R58)

Testing improvements:

  • Added a new acceptance test, TestAccLogsQueryDefinition_logGroupARNs, to verify the functionality of using log group ARNs in the log_group_names attribute. This test includes resource creation, attribute checks, and import state verification. (internal/service/logs/query_definition_test.go, internal/service/logs/query_definition_test.goR179-R210)
  • Introduced a helper function, testAccQueryDefinitionConfig_logGroupARNs, to generate test configurations for log group ARNs. This function creates multiple log groups and references their ARNs in the query definition. (internal/service/logs/query_definition_test.go, internal/service/logs/query_definition_test.goR293-R317)

Relations

Closes #37986

References

Output from Acceptance Testing

% make testacc TESTS=TestAccLogsQueryDefinition_logGroupARNs PKG=logs
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.24.4 test ./internal/service/logs/... -v -count 1 -parallel 1 -run='TestAccLogsQueryDefinition_logGroupARNs'  -timeout 360m -vet=off
2025/06/25 18:29:10 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/25 18:29:10 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccLogsQueryDefinition_logGroupARNs
=== PAUSE TestAccLogsQueryDefinition_logGroupARNs
=== CONT  TestAccLogsQueryDefinition_logGroupARNs
--- PASS: TestAccLogsQueryDefinition_logGroupARNs (25.53s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/logs       25.725s

...

Copy link
Contributor

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/logs Issues and PRs that pertain to the logs service. size/M Managed by automation to categorize the size of a PR. labels Jun 25, 2025
@robsonpiere robsonpiere marked this pull request as ready for review June 25, 2025 18:46
@robsonpiere robsonpiere requested a review from a team as a code owner June 25, 2025 18:46
Copy link
Contributor

github-actions bot commented Jun 25, 2025

✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible.

@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. enhancement Requests to existing resources that expand the functionality or scope. labels Jun 25, 2025
@ewbankkit ewbankkit self-assigned this Jun 29, 2025
@github-actions github-actions bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Jun 29, 2025
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccLogsQueryDefinition_' PKG=logs ACCTEST_PARALLELISM=3
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.24.4 test ./internal/service/logs/... -v -count 1 -parallel 3  -run=TestAccLogsQueryDefinition_ -timeout 360m -vet=off
2025/06/29 17:05:32 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/29 17:05:32 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccLogsQueryDefinition_basic
=== PAUSE TestAccLogsQueryDefinition_basic
=== RUN   TestAccLogsQueryDefinition_disappears
=== PAUSE TestAccLogsQueryDefinition_disappears
=== RUN   TestAccLogsQueryDefinition_rename
=== PAUSE TestAccLogsQueryDefinition_rename
=== RUN   TestAccLogsQueryDefinition_logGroups
=== PAUSE TestAccLogsQueryDefinition_logGroups
=== RUN   TestAccLogsQueryDefinition_logGroupARNs
=== PAUSE TestAccLogsQueryDefinition_logGroupARNs
=== CONT  TestAccLogsQueryDefinition_basic
=== CONT  TestAccLogsQueryDefinition_logGroups
=== CONT  TestAccLogsQueryDefinition_logGroupARNs
--- PASS: TestAccLogsQueryDefinition_basic (13.86s)
=== CONT  TestAccLogsQueryDefinition_rename
--- PASS: TestAccLogsQueryDefinition_logGroupARNs (14.53s)
=== CONT  TestAccLogsQueryDefinition_disappears
--- PASS: TestAccLogsQueryDefinition_logGroups (23.43s)
--- PASS: TestAccLogsQueryDefinition_disappears (11.04s)
--- PASS: TestAccLogsQueryDefinition_rename (21.18s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/logs	40.152s

Copy link
Contributor

@johnsonaj johnsonaj left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@ewbankkit
Copy link
Contributor

@robsonpiere Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 101895e into hashicorp:main Jul 1, 2025
41 checks passed
Copy link
Contributor

github-actions bot commented Jul 1, 2025

Warning

This Issue has been closed, meaning that any additional comments are much easier for the maintainers to miss. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v6.2.0 milestone Jul 1, 2025
@robsonpiere robsonpiere deleted the fix/query-definition-bug branch July 2, 2025 14:23
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Jul 2, 2025
Copy link
Contributor

github-actions bot commented Jul 2, 2025

This functionality has been released in v6.2.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link
Contributor

github-actions bot commented Aug 2, 2025

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/logs Issues and PRs that pertain to the logs service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: aws_cloudwatch_query_definition error when use cross account log groups
4 participants