# Diagnosing "no longer present in the configuration": orphaned state entries

## Symptom

```
Note: the current state contains resource instances that are no longer
present in the configuration ...
```

or plan wants to destroy resources you did not intend to remove. The state file references addresses with no matching config block.

## Cause

A config block was deleted or renamed without handling the state entry: a refactor removed the resource, a merge dropped the file, or a rename changed the address while the old address lingers.

## Confirmation

1. `terraform state list` shows the orphaned addresses. Compare with `git log`/`git diff` on the config: was the block deleted deliberately or lost accidentally?
2. Check whether the real object still exists (console/API). Orphaned state plus a live object is different from orphaned state plus a deleted object.

## Fix (pick one deliberately)

1. Accidental deletion: restore the config block. Next plan should be clean.
2. Deliberate removal, object should be destroyed: let the plan destroy it, or `terraform destroy -target=[address]` for a controlled removal.
3. Deliberate removal, object should live on unmanaged: `terraform state rm [address]` to untrack without destroying. (OpenTofu/Terraform 1.7+: prefer a `removed` block with `lifecycle { destroy = false }` so the intent is codified in config, not a CLI one-off.)
4. Rename (not removal): this is a `moved` block situation, not an orphan. Add the moved block so the plan renames instead of destroy/create.

## Verification

1. `terraform plan` shows only intended changes: no surprise destroys, no unexpected creates.
2. For `state rm`: the object still exists in the console and no longer appears in `terraform state list`.
