Skip to content

r/aws_cloudwatch_event_rule, aws_cloudwatch_event_target: Suppress equivalent 'event_bus_name' name/ARN diff#48986

Open
automationforthepeople wants to merge 1 commit into
hashicorp:mainfrom
automationforthepeople:b-events_event_bus_name_arn_diff_suppress
Open

r/aws_cloudwatch_event_rule, aws_cloudwatch_event_target: Suppress equivalent 'event_bus_name' name/ARN diff#48986
automationforthepeople wants to merge 1 commit into
hashicorp:mainfrom
automationforthepeople:b-events_event_bus_name_arn_diff_suppress

Conversation

@automationforthepeople

Copy link
Copy Markdown

Rollback Plan

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

Changes to Security Controls

No changes to security controls.

Description

aws_cloudwatch_event_rule and aws_cloudwatch_event_target accept either a bus name or ARN for event_bus_name, but the current implementation forces resource replacement when switching between the two forms — even though they reference the same physical event bus.

When create_before_destroy is active, the replacement cycle causes data loss: the EventBridge API's upsert semantics (PutRule/PutTargets) mean the "create" and "delete" operations target the same physical resource, so the net result is deletion.

This change adds a DiffSuppressFunc that extracts the bus name from an ARN before comparison, suppressing the false-positive diff. Follows the same pattern as vpclattice (suppressEquivalentIDOrARN, PR #32658).

AI Disclosure: AI assisted with identifying the root cause, researching precedent patterns in the codebase, and generating the initial implementation. The human author reviewed all code, verified test coverage, and understands the change fully.

Relations

Closes #48985

References

  • PR #32658 — identical pattern for vpclattice service network identifier
  • PR #30109 — relaxed validation to accept ARNs but did not add diff suppression
  • EventBridge PutRule APIEventBusName accepts name or ARN

Output from Acceptance Testing

% go test ./internal/service/events/... -run "TestSuppressEquivalentBusNameOrARN|TestBusNameFromNameOrARN" -v

--- PASS: TestBusNameFromNameOrARN (0.00s)
    --- PASS: TestBusNameFromNameOrARN/my-bus (0.00s)
    --- PASS: TestBusNameFromNameOrARN/arn:aws:events:us-east-1:123456789012:event-bus/default (0.00s)
    --- PASS: TestBusNameFromNameOrARN/arn:aws:events:us-east-1:123456789012:event-bus/my-bus (0.00s)
    --- PASS: TestBusNameFromNameOrARN/default (0.00s)
    --- PASS: TestBusNameFromNameOrARN/arn:aws-us-gov:events:us-gov-west-1:123456789012:event-bus/custom_bus-123 (0.00s)
--- PASS: TestSuppressEquivalentBusNameOrARN (0.00s)
    --- PASS: TestSuppressEquivalentBusNameOrARN/same_name (0.00s)
    --- PASS: TestSuppressEquivalentBusNameOrARN/govcloud_ARN_to_name (0.00s)
    --- PASS: TestSuppressEquivalentBusNameOrARN/default_bus_name_vs_default_ARN (0.00s)
    --- PASS: TestSuppressEquivalentBusNameOrARN/different_bus_names (0.00s)
    --- PASS: TestSuppressEquivalentBusNameOrARN/name_to_equivalent_ARN (0.00s)
    --- PASS: TestSuppressEquivalentBusNameOrARN/same_ARN (0.00s)
    --- PASS: TestSuppressEquivalentBusNameOrARN/ARN_to_equivalent_name (0.00s)
    --- PASS: TestSuppressEquivalentBusNameOrARN/name_vs_different_ARN (0.00s)
    --- PASS: TestSuppressEquivalentBusNameOrARN/ARNs_in_different_regions_same_bus_name (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/events	0.112s

Note: We do not have access to run full acceptance tests (make testacc) against live AWS infrastructure. The unit tests verify the suppress logic. Existing acceptance tests TestAccEventsRule_eventBusARN and TestAccEventsTarget_eventBusARN exercise the ARN code path and should continue to pass unchanged.

@automationforthepeople
automationforthepeople requested a review from a team as a code owner July 16, 2026 18:48
@dosubot dosubot Bot added the bug Addresses a defect in current functionality. label Jul 16, 2026
@github-actions

Copy link
Copy Markdown
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/events Issues and PRs that pertain to the events service. size/L Managed by automation to categorize the size of a PR. labels Jul 16, 2026
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Addresses a defect in current functionality. service/events Issues and PRs that pertain to the events service. size/L 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.

aws_cloudwatch_event_rule and aws_cloudwatch_event_target: Changing event_bus_name between name and ARN causes resource deletion without recreation

2 participants