{
  "id": "terraform/terraform-validate-undeclared-variable",
  "signature": "Error: Reference to undeclared input variable: \"var.environment\" is not declared in the root module",
  "signature_zh": "错误：引用未声明的输入变量：根模块中未声明 \"var.environment\"",
  "regex": "Reference to undeclared input variable.*is not declared",
  "domain": "terraform",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "A configuration file references a variable (var.*) that has not been declared with a variable block in any of the module's .tf files.",
  "root_cause_type": "generic",
  "root_cause_zh": "配置文件引用了变量（var.*），但该模块的任何 .tf 文件中都没有使用 variable 块声明该变量。",
  "versions": [
    {
      "version": "Terraform 1.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Terraform 1.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Terraform 1.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The .tfvars file only provides values; the variable must first be declared with a variable block in a .tf file.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changing the prefix doesn't create the variable. 'local' requires a locals block, which is a different construct.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The issue is a missing variable declaration in the root module, not a missing module. Init doesn't add variable declarations.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Declare the missing variable in a .tf file (e.g., variables.tf) with an appropriate type and optional default.",
      "success_rate": 0.95,
      "how": "Declare the missing variable in a .tf file (e.g., variables.tf) with an appropriate type and optional default.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the variable is meant to come from a module, ensure the module's outputs are correctly referenced. Use module.<module_name>.<output_name> instead of var.<name>.",
      "success_rate": 0.85,
      "how": "If the variable is meant to come from a module, ensure the module's outputs are correctly referenced. Use module.<module_name>.<output_name> instead of var.<name>.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the variable is not needed, replace the reference with a literal value or a local value.",
      "success_rate": 0.8,
      "how": "If the variable is not needed, replace the reference with a literal value or a local value.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在 .tf 文件（如 variables.tf）中声明缺失的变量，包含适当的类型和可选的默认值。",
    "如果变量来自模块，确保正确引用模块的输出。使用 module.<module_name>.<output_name> 而不是 var.<name>。",
    "如果不需要该变量，将引用替换为字面量或 local 值。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.hashicorp.com/terraform/language/values/variables",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-03-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}