{
  "id": "terraform/insufficient-ip-addresses-in-subnet",
  "signature": "Error: error creating EC2 Instance: insufficient IP addresses in subnet (subnet-abc123) when creating a new instance",
  "signature_zh": "错误：创建 EC2 实例时出错：子网 (subnet-abc123) 中的 IP 地址不足，无法创建新实例",
  "regex": "error creating EC2 Instance: insufficient IP addresses in subnet \\([a-z0-9-]+\\) when creating a new instance",
  "domain": "terraform",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "The AWS subnet has exhausted its available IP addresses, often due to too many ENIs or instances consuming the CIDR range, or the subnet's CIDR block being too small.",
  "root_cause_type": "generic",
  "root_cause_zh": "AWS 子网已耗尽可用 IP 地址，通常是由于过多的 ENI 或实例消耗了 CIDR 范围，或者子网的 CIDR 块太小。",
  "versions": [
    {
      "version": "Terraform v1.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Terraform v1.6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Terraform v1.7",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "AWS Provider v5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increasing the instance count in the Terraform configuration without adjusting the subnet CIDR",
      "why_fails": "More instances will consume more IPs, worsening the shortage; Terraform will fail with the same error for each new instance.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Deleting unused instances manually via AWS console but not updating Terraform state",
      "why_fails": "Terraform state still tracks deleted instances, causing drift; subsequent apply may try to recreate them, consuming IPs again.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Changing the subnet ID to a different existing subnet without verifying its IP availability",
      "why_fails": "The new subnet may also have limited IPs; without checking available addresses, the error may simply move to another subnet.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase the subnet CIDR block size: update `cidr_block = \"10.0.1.0/24\"` to a larger range like `10.0.1.0/23` (requires recreating the subnet) or add a new subnet with a larger CIDR.",
      "success_rate": 0.95,
      "how": "Increase the subnet CIDR block size: update `cidr_block = \"10.0.1.0/24\"` to a larger range like `10.0.1.0/23` (requires recreating the subnet) or add a new subnet with a larger CIDR.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `aws ec2 describe-subnets --subnet-ids subnet-abc123 --query 'Subnets[0].AvailableIpAddressCount'` to check available IPs, then reduce instance count or use a different subnet with free IPs.",
      "success_rate": 0.8,
      "how": "Use `aws ec2 describe-subnets --subnet-ids subnet-abc123 --query 'Subnets[0].AvailableIpAddressCount'` to check available IPs, then reduce instance count or use a different subnet with free IPs.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Implement a lifecycle policy to terminate idle instances or use auto-scaling with a minimum/maximum size to free IPs dynamically.",
      "success_rate": 0.7,
      "how": "Implement a lifecycle policy to terminate idle instances or use auto-scaling with a minimum/maximum size to free IPs dynamically.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Increase the subnet CIDR block size: update `cidr_block = \"10.0.1.0/24\"` to a larger range like `10.0.1.0/23` (requires recreating the subnet) or add a new subnet with a larger CIDR.",
    "Use `aws ec2 describe-subnets --subnet-ids subnet-abc123 --query 'Subnets[0].AvailableIpAddressCount'` to check available IPs, then reduce instance count or use a different subnet with free IPs.",
    "Implement a lifecycle policy to terminate idle instances or use auto-scaling with a minimum/maximum size to free IPs dynamically."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.aws.amazon.com/vpc/latest/userguide/subnet-sizing.html",
  "official_doc_section": null,
  "error_code": "InsufficientIPAddressesInSubnet",
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}