{
  "id": "terraform/duplicate-resource-name-in-module",
  "signature": "Error: Duplicate resource \"aws_instance\" configuration: a resource with the address \"module.ec2.aws_instance.web\" already exists",
  "signature_zh": "错误：重复的资源 \"aws_instance\" 配置：地址为 \"module.ec2.aws_instance.web\" 的资源已存在",
  "regex": "Duplicate resource.*configuration.*already exists",
  "domain": "terraform",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Two or more resource blocks with the same resource type and name exist within the same module, causing a duplicate definition.",
  "root_cause_type": "generic",
  "root_cause_zh": "同一模块中存在两个或更多具有相同资源类型和名称的资源块，导致重复定义。",
  "versions": [
    {
      "version": "Terraform v1.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Terraform v1.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Terraform v1.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Add count or for_each to the duplicate resource block",
      "why_fails": "Count/for_each creates multiple instances but doesn't resolve duplicate block definitions.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Rename the module call in the root module",
      "why_fails": "The duplicate is within the same module, not at the call site.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "Delete the .terraform directory and re-run init",
      "why_fails": "The config file itself has duplicates; init doesn't fix config errors.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Remove or rename one of the duplicate resource blocks in the module configuration file. For example, change `resource \"aws_instance\" \"web\"` to `resource \"aws_instance\" \"web2\"` and update references.",
      "success_rate": 0.95,
      "how": "Remove or rename one of the duplicate resource blocks in the module configuration file. For example, change `resource \"aws_instance\" \"web\"` to `resource \"aws_instance\" \"web2\"` and update references.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a single resource block with count or for_each if multiple instances are needed: `resource \"aws_instance\" \"web\" { count = 2 ... }`",
      "success_rate": 0.9,
      "how": "Use a single resource block with count or for_each if multiple instances are needed: `resource \"aws_instance\" \"web\" { count = 2 ... }`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Remove or rename one of the duplicate resource blocks in the module configuration file. For example, change `resource \"aws_instance\" \"web\"` to `resource \"aws_instance\" \"web2\"` and update references.",
    "Use a single resource block with count or for_each if multiple instances are needed: `resource \"aws_instance\" \"web\" { count = 2 ... }`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.hashicorp.com/terraform/language/resources/syntax",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-01-25",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}