{
  "id": "terraform/targeted-apply-without-plan",
  "signature": "Error: Invalid target: the given target is not valid: resource address must be a valid resource instance",
  "signature_zh": "错误：无效的目标：给定的目标无效：资源地址必须是有效的资源实例",
  "regex": "Invalid target: the given target is not valid: resource address must be a valid resource instance",
  "domain": "terraform",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The -target option was used with an incorrectly formatted resource address, such as missing the resource type or name.",
  "root_cause_type": "generic",
  "root_cause_zh": "使用了格式不正确的资源地址的 -target 选项，例如缺少资源类型或名称。",
  "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": "Use the resource name only without the type, e.g., -target=my_resource.",
      "why_fails": "Terraform requires the full address format: resource_type.resource_name. A bare name is not recognized.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use -target with a module path that doesn't exist.",
      "why_fails": "The target must reference an existing resource in the configuration; non-existent paths cause the same error.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Run terraform apply without any target, ignoring the need for targeted operations.",
      "why_fails": "This applies all changes, which may not be desired and could cause unintended side effects.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use the correct resource address format: terraform apply -target=\"aws_instance.web\". For modules: -target=\"module.vpc.aws_subnet.public\". Verify the address with terraform state list.",
      "success_rate": 0.95,
      "how": "Use the correct resource address format: terraform apply -target=\"aws_instance.web\". For modules: -target=\"module.vpc.aws_subnet.public\". Verify the address with terraform state list.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If targeting a resource with count or for_each, include the index: -target=\"aws_instance.web[0]\" or -target='aws_instance.web[\"key1\"]'.",
      "success_rate": 0.9,
      "how": "If targeting a resource with count or for_each, include the index: -target=\"aws_instance.web[0]\" or -target='aws_instance.web[\"key1\"]'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use terraform plan -target to preview before applying: terraform plan -target=\"aws_instance.web\" -out=tfplan && terraform apply tfplan.",
      "success_rate": 0.85,
      "how": "Use terraform plan -target to preview before applying: terraform plan -target=\"aws_instance.web\" -out=tfplan && terraform apply tfplan.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用正确的资源地址格式：terraform apply -target=\"aws_instance.web\"。对于模块：-target=\"module.vpc.aws_subnet.public\"。使用 terraform state list 验证地址。",
    "如果针对具有 count 或 for_each 的资源，请包含索引：-target=\"aws_instance.web[0]\" 或 -target='aws_instance.web[\"key1\"]'。",
    "在应用之前使用 terraform plan -target 进行预览：terraform plan -target=\"aws_instance.web\" -out=tfplan && terraform apply tfplan。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.hashicorp.com/terraform/cli/commands/plan#target-address",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.81,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-11-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}