Interview Prep/Terraform/Lost, Corrupted and Drifted State

`terraform plan` shows `aws_route53_record` will be created, but apply fails with `Tried to create resource record set ... but it already exists`.

IntermediateTroubleshootingLost, Corrupted and Drifted State
Answer

Likely causes → The record was created manually or by another stack (or ExternalDNS in Kubernetes). Terraform doesn't know it exists.

Diagnose → aws route53 list-resource-record-sets --hosted-zone-id Z123 --query "ResourceRecordSets[?Name=='api.example.com.']"

Fix → Import it (id = "Z123_api.example.com_A"), or set allow_overwrite = true if Terraform should take ownership.

Prevent → Split DNS ownership clearly (for example, ExternalDNS owns *.apps, Terraform owns everything else).

All Terraform questions Roadmap: Terraform in production

More on Lost, Corrupted and Drifted State