Terraform Apply Error: Resource Already Exists Outside State
Resource was created manually in the cloud console and is missing from `terraform.tfstate`.
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.1.0
Identifier: Terraform Apply Error
Platform: DevOps
Common Root Causes:
- Resource was created manually in the cloud console and is missing from `terraform.tfstate`.
Interactive Diagnostic Checklist
Verified Solutions:
- Add a declarative `import { to = ... id = ... }` block to adopt the resource cleanly.
Safe Diagnostic Command:
terraform plan
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.
Technical Explanation
Resource was created manually in the cloud console and is missing from `terraform.tfstate`. Recommended diagnostic: `terraform plan`. Remediation: Add a declarative `import { to = ... id = ... }` block to adopt the resource cleanly.
Worked Examples
- Run `terraform plan` to verify root cause before applying the remediation.
Limitations & Assumptions
- Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.
Source References & Verification
Resource ID: err-tf-state-drift-resource-already-exists · Independently verified: 2026-11-25