Skip to content

Conversation

@KyungHwanKim-devs
Copy link

@KyungHwanKim-devs KyungHwanKim-devs commented Jan 4, 2026

Refs #24704

Summary

  • Keep the existing diagnostic hint for resource conflict errors, but make it more precise and less noisy.
  • Tighten the match to only already exists/EntityAlreadyExists so unrelated duplicate errors do not get a misleading hint.
  • Expand the hint message to cover both common root causes: missing moved blocks during refactors and provider-side asynchronous deletes/eventual consistency.
  • Update tests and the changelog entry to match the refined behavior and wording.

Rationale / Background

This issue has two recurring causes:

  1. A refactor (rename or module move) where Terraform sees the old and new addresses as different resources. Without moved blocks, Terraform plans a destroy+create and may attempt the create before the old object is fully gone.
  2. Provider-side delete operations that return before the object is fully removed (eventual consistency), which can surface as already exists errors on replacement.

The hint should steer users toward the correct fix without over-triggering on unrelated errors. This change keeps the hint but narrows the match to explicit already exists signals and clarifies the two likely root causes in the message.

User-facing Behavior

No behavior change to planning or apply execution. A warning hint is appended only when an error explicitly indicates the object already exists.

Testing

  • go test ./internal/terraform -run TestHintIfAlreadyExists

Target Release

1.15.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

No. This only adjusts diagnostic messaging.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@KyungHwanKim-devs KyungHwanKim-devs requested a review from a team as a code owner January 4, 2026 11:17
@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Jan 4, 2026

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Gemini Agent seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA.
If you have already a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

Some provider errors indicate that a resource already exists during a replacement. This commonly happens when a resource is renamed or moved without a moved block; Terraform sees the old and new addresses as distinct and may attempt the create before the old object is fully gone. Add a diagnostic hint for explicit already exists signals to recommend moved blocks or terraform state mv.

Refs hashicorp#24704

Signed-off-by: KyungHwanKim-devs <kkhdevs@gmail.com>
Signed-off-by: KyungHwanKim-devs <kkhdevs@gmail.com>
Signed-off-by: KyungHwanKim-devs <kkhdevs@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants