How to fix Error: Error creating EC2 Instance: InsufficientInstanceCapacity in Terraform

TerraformINTERMEDIATEMEDIUMUpdated Dec 30, 2025· 130 views

This error occurs when AWS lacks sufficient On-Demand capacity to provision your requested EC2 instance type in the chosen Availability Zone. Capacity constraints are usually temporary and can be resolved by trying different AZs, instance types, or retrying after a few minutes.

Quick fix

Fixes Error: Error creating EC2 Instance: InsufficientInstanceCapacity

terraform apply
  1. Wait and retry the deployment
  2. Remove Availability Zone specification to let AWS choose
  3. Try a different Availability Zone
  4. Try a different instance type
terraform — error
terraform apply
Error: Error creating EC2 Instance: InsufficientInstanceCapacity

What this error means

The InsufficientInstanceCapacity error indicates that AWS does not currently have enough available On-Demand resources to fulfill your request for a specific instance type in your requested Availability Zone. This is a temporary capacity constraint that AWS experiences during periods of high demand. The error is not due to misconfiguration or insufficient permissions—rather, it reflects real-time resource availability in AWS infrastructure.

Typical symptoms

  • Terraform apply fails with 'InsufficientInstanceCapacity' error
  • EC2 instance creation fails even with valid IAM permissions and credentials
  • Error persists after retrying immediately but may succeed later
  • Specific instance types unavailable in certain Availability Zones
  • Auto Scaling Groups fail to launch instances

Common causes

  1. High demand for the specific instance type in the region/AZ you selected
  2. AWS capacity limitations for the instance type (especially with specialty instances like GPU or high-memory types)
  3. Your chosen Availability Zone temporarily has insufficient capacity
  4. Too many instances requested simultaneously in the same AZ
  5. Using a specific AZ that is oversubscribed or under maintenance

How to fix "Error: Error creating EC2 Instance: InsufficientInstanceCapacity"

1Wait and retry the deployment

AWS capacity is highly dynamic and changes frequently. Wait 2-5 minutes and re-run terraform apply. The capacity issue may resolve as AWS provisions additional resources.

bash
terraform apply
2Remove Availability Zone specification to let AWS choose

Instead of specifying a hardcoded Availability Zone, let AWS select from available capacity across all AZs in the region. Remove or comment out the availability_zone parameter.

Before:

hcl
resource "aws_instance" "example" {
  ami               = "ami-12345678"
  instance_type     = "m5.large"
  availability_zone = "us-east-1a"
}

After:

hcl
resource "aws_instance" "example" {
  ami           = "ami-12345678"
  instance_type = "m5.large"
  # availability_zone removed - AWS will choose from available capacity
}
3Try a different Availability Zone

If you must specify an AZ, try different ones. Capacity varies by AZ, and another AZ in the same region may have capacity available.

hcl
resource "aws_instance" "example" {
  ami               = "ami-12345678"
  instance_type     = "m5.large"
  availability_zone = "us-east-1b"  # Changed from us-east-1a
}

Or use multiple AZs with Auto Scaling Groups for automatic failover:

hcl
resource "aws_autoscaling_group" "example" {
  availability_zones = ["us-east-1a", "us-east-1b", "us-east-1c"]
  # AWS will launch in any AZ with available capacity
}
4Try a different instance type

If your specific instance type is unavailable, switch to an alternative in the same family with similar specifications. For example, if m5.large is unavailable, try m5.xlarge, m6i.large, or t3.large.

hcl
resource "aws_instance" "example" {
  ami           = "ami-12345678"
  instance_type = "m6i.large"  # Changed from m5.large
}
5Reduce the number of instances in a single request

If deploying multiple instances, split them into smaller groups. This distributes the load and improves the chance of successful provisioning.

Before:

hcl
resource "aws_instance" "fleet" {
  count         = 10
  ami           = "ami-12345678"
  instance_type = "m5.large"
}

After:

hcl
resource "aws_instance" "fleet" {
  count         = 3  # Reduced from 10
  ami           = "ami-12345678"
  instance_type = "m5.large"
}

# Run terraform apply multiple times or in batches
6Use On-Demand Capacity Reservations for guaranteed capacity

If this is production-critical, reserve EC2 capacity in advance using Capacity Reservations. This guarantees availability but incurs charges whether the capacity is used or not.

hcl
resource "aws_ec2_capacity_reservation" "example" {
  instance_type           = "m5.large"
  instance_platform       = "Linux/UNIX"
  availability_zone       = "us-east-1a"
  instance_count          = 5
}

resource "aws_instance" "example" {
  ami                          = "ami-12345678"
  instance_type                = "m5.large"
  capacity_reservation_id      = aws_ec2_capacity_reservation.example.id
}
7Consider Spot Instances as a temporary workaround

Spot Instances are much cheaper and have greater availability. Use them for non-critical or temporary workloads.

hcl
resource "aws_instance" "example" {
  ami           = "ami-12345678"
  instance_type = "m5.large"
  instance_interruption_behavior = "stop"
  spot_price    = "0.05"  # Set a bid price
}

Advanced notes

AWS capacity constraints are a natural part of cloud infrastructure management. The capacity available in any region or AZ fluctuates based on overall AWS customer demand and infrastructure maintenance. High-demand instance types (GPU, high-memory, or specialized types like g5.12xlarge) are more prone to capacity issues. For production workloads, use Capacity Reservations or Reserved Instances to guarantee availability, though this incurs charges whether capacity is used. The Terraform AWS provider will retry failed instance launches with exponential backoff, which can result in extended deployment times (up to 50 minutes) before ultimately failing. Setting wait_for_capacity_timeout in certain resources can help control this behavior. For Auto Scaling Groups, AWS recommends specifying multiple instance types and AZs to improve provisioning success rates.

Frequently asked questions

What does "Error: Error creating EC2 Instance: InsufficientInstanceCapacity" mean?
The InsufficientInstanceCapacity error indicates that AWS does not currently have enough available On-Demand resources to fulfill your request for a specific instance type in your requested Availability Zone. This is a temporary capacity constraint that AWS experiences during periods of high demand. The error is not due to misconfiguration or insufficient permissions—rather, it reflects real-time resource availability in AWS infrastructure.
How do I fix "Error: Error creating EC2 Instance: InsufficientInstanceCapacity"?
This error occurs when AWS lacks sufficient On-Demand capacity to provision your requested EC2 instance type in the chosen Availability Zone. Capacity constraints are usually temporary and can be resolved by trying different AZs, instance types, or retrying after a few minutes.
What causes "Error: Error creating EC2 Instance: InsufficientInstanceCapacity"?
High demand for the specific instance type in the region/AZ you selected AWS capacity limitations for the instance type (especially with specialty instances like GPU or high-memory types) Your chosen Availability Zone temporarily has insufficient capacity
Is the "Error: Error creating EC2 Instance: InsufficientInstanceCapacity" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading