{
  "id": "terraform/resource-config-key-too-deep",
  "signature": "Error: Invalid resource instance key: resource instance key must be a positive integer or a string",
  "signature_zh": "错误：无效的资源实例键：资源实例键必须是正整数或字符串",
  "regex": "Invalid resource instance key",
  "domain": "terraform",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Using a complex expression (like a list or map) as the key in a resource instance when Terraform expects a simple integer or string.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 Terraform 期望简单整数或字符串时，使用了复杂表达式（如列表或映射）作为资源实例键。",
  "versions": [
    {
      "version": "1.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Wrapping the expression in tostring() or tolist() does not change the fundamental type mismatch.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using count.index or for_each.key in a nested resource block still fails because the key must be a literal.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Simplify the key expression to a single variable or literal. For example, use 'var.environment' instead of 'var.environment[0]' if the key is meant to be a string.",
      "success_rate": 0.9,
      "how": "Simplify the key expression to a single variable or literal. For example, use 'var.environment' instead of 'var.environment[0]' if the key is meant to be a string.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Restructure the configuration to use a for_each with a map that has simple keys, or use count with a list.",
      "success_rate": 0.85,
      "how": "Restructure the configuration to use a for_each with a map that has simple keys, or use count with a list.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将键表达式简化为单个变量或字面值。例如，如果键应为字符串，使用 'var.environment' 而不是 'var.environment[0]'。",
    "重构配置，使用具有简单键的映射的 for_each，或使用 count 与列表。"
  ],
  "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.82,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-10-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}