TL;DR: Something in your config references a resource that doesn't exist: a typo, a deleted block, or a renamed label whose references weren't updated. The error names the file, line, and address. Fix the reference, or add the missing resource back.

```text
Error: Reference to undeclared resource

  on retire.tf line 5, in output "build_info_path":
   5:   value = local_file.build_info.filename

There is no managed resource "local_file" "build_info" definition in the root
module.
```

## Steps

1. Read the address in the error (`local_file.build_info` above) and the location of the reference (file, line).
   Expected: you know exactly which reference is dangling.
2. Search for the resource block: `grep -rn 'resource "local_file" "build_info"' .`
   Expected: either no block (it was deleted or never existed) or a block with a different label (it was renamed).
3. Fix it one of these ways:
   - Typo: correct the reference to the real label.
   - Deleted by accident: restore the block.
   - Renamed on purpose: update every reference (outputs, locals, other resources), or add a `moved` block so tofu tracks the rename.
   - Retiring on purpose: delete the consumers too, or use a `removed` block to forget it without destroying.
   Expected: no dangling references remain.
4. Run `tofu validate`.
   Expected: `Success! The configuration is valid.`

## When this applies

- `tofu plan` or `tofu validate` fails naming a `type.name` address with `no ... definition in the root module` (or in a child module).
- Right after renaming or deleting a resource block.

## When it doesn't apply

- `Error: Reference to undeclared input variable` is the variable version; same idea, different fix location.
- `Error: Reference to undeclared data source` means a `data` block is missing.
- A reference that exists but has `count = 0` fails differently (`Invalid index`); that's not this error.

## Tool versions

All OpenTofu versions.

## Why it happens

References are resolved statically before anything is planned. A reference to an address with no block is a config bug by definition, so tofu fails fast and names every dangling reference instead of guessing.

## Edge cases

- Renames dangle in bulk: renaming a resource label breaks every reference at once. A `moved { from, to }` block renames the state address too, so you don't get this error at all.
- `tofu state mv` renames state without touching config; if you do one without the other, expect this error or a destroy-and-recreate plan.
- Module-internal references say `in module "name"` instead of `in the root module`; fix them inside the module source.