{
  "id": "terraform/lifecycle-precondition-failed",
  "signature": "Error: Resource precondition failed: All preconditions must be met",
  "signature_zh": "错误：资源前置条件失败：必须满足所有前置条件",
  "regex": "Resource precondition failed: All preconditions must be met",
  "domain": "terraform",
  "category": "assertion_error",
  "subcategory": null,
  "root_cause": "A lifecycle precondition block in a resource configuration evaluated to false during the plan or apply phase.",
  "root_cause_type": "generic",
  "root_cause_zh": "资源配置中的生命周期前置条件块在计划或应用阶段评估为假。",
  "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"
    },
    {
      "version": "1.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Comment out the precondition block and re-apply without fixing the underlying condition.",
      "why_fails": "The precondition exists to enforce an invariant; bypassing it may lead to incorrect infrastructure state.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Change the precondition condition to always true without understanding why it failed.",
      "why_fails": "This defeats the purpose of the precondition and masks real issues.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Run terraform plan -refresh-only to update state before applying.",
      "why_fails": "Preconditions are evaluated during plan; refresh-only doesn't change the logical condition causing the failure.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Inspect the precondition condition expression. For example, if precondition { condition = var.instance_count > 0 error_message = \"Instance count must be positive\" } fails, set var.instance_count to a positive value. Use terraform console to test the condition: terraform console then evaluate var.instance_count > 0.",
      "success_rate": 0.9,
      "how": "Inspect the precondition condition expression. For example, if precondition { condition = var.instance_count > 0 error_message = \"Instance count must be positive\" } fails, set var.instance_count to a positive value. Use terraform console to test the condition: terraform console then evaluate var.instance_count > 0.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the precondition depends on data source output, ensure the data source is correctly configured and returns expected values. Add a depends_on to the data source if needed.",
      "success_rate": 0.85,
      "how": "If the precondition depends on data source output, ensure the data source is correctly configured and returns expected values. Add a depends_on to the data source if needed.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Temporarily remove or modify the precondition to allow the apply to proceed, then fix the root cause and re-add the precondition.",
      "success_rate": 0.75,
      "how": "Temporarily remove or modify the precondition to allow the apply to proceed, then fix the root cause and re-add the precondition.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "检查前置条件表达式。例如，如果 precondition { condition = var.instance_count > 0 error_message = \"实例计数必须为正\" } 失败，请将 var.instance_count 设置为正值。使用 terraform console 测试条件：terraform console 然后评估 var.instance_count > 0。",
    "如果前置条件依赖于数据源输出，请确保数据源配置正确并返回预期值。如果需要，向数据源添加 depends_on。",
    "暂时删除或修改前置条件以允许应用继续，然后修复根本原因并重新添加前置条件。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle#precondition-and-postcondition",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-02-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}