**TL;DR:** Two blocks declare the same address, usually from a merge that added the same resource twice or a copy-paste. The error names both locations; the fix is deletion, not renaming one side blindly. Check git blame or the merge that introduced the duplicate. Delete the duplicate, do not rename one side to "fix" it.

## The error

```text
Error: Duplicate resource "aws_instance" configuration

  on main.tf line 10:
  10: resource "aws_instance" "web" {

A aws_instance resource named "web" was already declared at vpc.tf line 4.
```

## What you are seeing

```
Error: Duplicate resource "aws_instance" configuration

  on main.tf line 10:
  10: resource "aws_instance" "web" {

A aws_instance resource named "web" was already declared at vpc.tf line 4.
```

Two blocks claim the same address. Terraform cannot guess which one you meant.

## First response

1. The error names both files and lines. Open both. One of them is the keeper, usually the one matching the state (`terraform state list` shows the live address).
2. Check git blame or the merge that introduced the duplicate. Merges that add the same resource on both sides are the classic cause.
3. Delete the duplicate, do not rename one side to "fix" it. Renaming creates a new address: the next plan shows a destroy and a create, which is not what a duplicate cleanup should do.

## Rules for agents

1. After deleting the duplicate, run `terraform plan`. It should be clean or show only intended changes. If it wants to destroy the resource, you deleted the wrong copy.
2. Duplicate variables and outputs follow the same rule: the error names both declarations, keep the one the rest of the config references.
3. Copy-paste duplication across files is a lint problem. `tflint` and even `terraform validate` catch these before they reach a human reviewer.
4. In generated config (from `-generate-config-out` or tooling), duplicates mean the generator ran twice or two generators overlap. Fix the generator invocation, not just the output.

## When to use this

- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: Terraform.
- You want the fastest verified fix before digging through logs.

## When not to use this

- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.

## Compatibility

- Not pinned to a specific version; follows current Terraform behavior.