Cloud Computing
VERIFIED FIXES

Route53 record resource recreated by Terraform every plan/apply despite no config change

Environment

Environment

Terraform v1.5 with aws provider 4.x managing Route53 hosted zone records (A/AAAA and ALIAS records). CI runs terraform plan/apply repeatedly; team uses git-driven pipeline.

Symptoms

Symptoms

Each 'terraform plan' shows a 'replace' for several aws_route53_record resources even when no changes were made to .tf files. Apply recreates records briefly, causing short DNS propagation blips.

Observations

Observations

Diff shows only ordering of values in provider response or computed attributes toggling between representation forms (e.g., alias target list ordering or trailing dots). Resource IDs appear consistent but Terraform state marks resources to force-recreate. Pinning provider to earlier minor release temporarily stops behavior.

Already attempted

Already attempted

Tried 'terraform refresh' and state rm/ import cycle for one affected record; attempted adding lifecycle ignore_changes for TTL but replacements persisted. Upgrading/downgrading provider changes which records are affected.

Question

Question

Why does Terraform decide to replace static Route53 records when nothing changed, and how can I stop unnecessary replacements without losing state or causing DNS blips?

COMMUNITY RESPONSES

Verified community troubleshooting

1 reply
0
williamweb Answer
user
Posted 1mo ago • 0 confirmations

Most likely the provider is returning attributes in a different form/order each read. First pin the aws provider to a stable minor version and run 'terraform init' then 'terraform plan' to see if plan stops showing replaces. If diffs remain and they involve alias/list ordering, canonicalize the values (add trailing dots to FQDNs, sort lists in code) or add a temporary lifecycle.ignore_changes for the computed fields causing churn. To verify, run 'terraform plan' twice; no-change output proves the fix. If you import/remove state, do it in a maintenance window and keep DNS TTLs low for quick rollback.

Showing 1 of 1 community responses
AI DIAGNOSTICS

Incident analysis

Updated 1mo ago• Trouble ID

Most likely causes

Provider returns non-deterministic ordering or representation for record attributes (alias targets, multi-value answers); Terraform sees a diff and replaces resource. 85%
Terraform provider bug between minor versions changing computed attribute names/format. 60%
State drift caused by manual console edits producing slightly different canonical forms (trailing dot vs no trailing dot). 40%

Summary

Terraform uses the provider's API responses to compute the current state; non-deterministic ordering or format differences (alias target lists, trailing dot normalization, or provider bug) can lead to spurious diffs. Common remedies: pin provider version that behaves deterministically, use lifecycle.ignore_changes for computed attributes that flip, normalize resource attributes (explicit trailing dots, canonicalize list ordering), or perform a careful state import/refresh after upgrade. Avoid scripted state modifications unless necessary.

Suggested Fixes

Diagnostic step 1
Pin the AWS provider to the last known-good minutely release in your module/provider blocks and run 'terraform init -upgrade' in a test workspace to confirm stability.
Diagnostic step 2
Run 'terraform plan -out=planfile' and inspect detailed differences; canonicalize attributes (add trailing dots to FQDNs) or sort lists in code if possible.
Diagnostic step 3
If the diff is only for computed attributes, add a targeted lifecycle.ignore_changes for those attributes (temporary): lifecycle { ignore_changes = ["alias.0.*"] }

Continue troubleshooting

Matched from the title, description and tags