What it means
Terraform only manages what's in its state. A resource created by hand, by another configuration, or lost from state looks new, and the cloud rejects the duplicate name.
Causes and fixes
Most likely first. Run the check, and if it matches, apply the fix.
1. Created outside Terraform
Check:
terraform state list | grep <name>
Fix: Add an import block (or terraform import) and plan until there are no changes.
2. Renamed in code without moving it in state
Check:
terraform plan # one destroy, one create
Fix: Add a moved block from the old address to the new.
Fix it yourself
A live machine in your browser with this problem already on it. The grader checks the result.
- Adopt an Existing Value With an import Blockmedium 9 min
- Bring a Hand-Made Bucket Under OpenTofumedium 12 min
- A Rename That Would Delete the Logs Bucketmedium 10 min
No account needed for your first tries.
Related errors
- Error acquiring the state lock
Another run holds the state lock, or a crashed run left it behind.