How to fix Error creating EC2 Instance: VcpuLimitExceeded in Terraform
You've reached your AWS account's vCPU quota limit for EC2 instances. AWS enforces soft limits on the number of vCPUs you can use in a region. This error occurs when trying to launch an instance that would exceed your current quota.
Quick fix
Fixes VcpuLimitExceeded
aws service-quotas request-service-quota-increase \
--service-code ec2 \
--quota-code L-1216C47A \
--desired-value 20- Check your current vCPU quota in AWS Console
- Request a vCPU quota increase
- Workaround: Use a smaller instance type
- Workaround: Launch in a different AWS region
aws service-quotas request-service-quota-increase \--service-code ec2 \--quota-code L-1216C47A \--desired-value 20Error creating EC2 Instance: VcpuLimitExceeded
What this error means
AWS uses a quota system to manage resource capacity across regions and instance types. Each AWS account has a default vCPU limit (typically 5 vCPUs for On-Demand Standard instances). When Terraform attempts to create an EC2 instance, AWS checks if the instance type's vCPUs would exceed your account's remaining quota. If it would, the VcpuLimitExceeded error is returned. This is not a permanent restriction—AWS allows you to request quota increases.
Typical symptoms
- Terraform apply fails during EC2 instance creation with 'VcpuLimitExceeded' error
- Error mentions 'You have requested more vCPU capacity than your current vCPU limit'
- Error specifies a vCPU limit of 0 or a low number
- Works in different AWS regions or with smaller instance types
- Worked previously but now fails after launching other instances
Common causes
- Current vCPU quota is too low for the instance type you're trying to launch
- Default AWS account quota for Standard instances is exhausted by other running instances
- Spot instance quotas and On-Demand quotas are separate; you may have confused them
- Quota differs by instance family (Standard, GPU, Memory-optimized, etc.); instance type belongs to family with insufficient quota
- Regional quotas: different AWS regions have separate quotas
- Quota set to 0 vCPUs (common for new accounts for certain instance families)
How to fix "Error creating EC2 Instance: VcpuLimitExceeded"
Navigate to the AWS Service Quotas console to see your current limits:
1. Log into your AWS account
2. Go to Service Quotas (search in AWS Console)
3. Select Amazon Elastic Compute Cloud (Amazon EC2)
4. Search for quotas like "Running On-Demand Standard" or your instance type
5. Note the "Quota value" (current limit) and "Usage" (vCPUs in use)
The instance type in your Terraform config belongs to an instance family. For example:
- t2.micro (1 vCPU) → Standard family
- t3.large (2 vCPUs) → Standard family
- m5.xlarge (4 vCPUs) → Standard family
- c5.2xlarge (8 vCPUs) → Standard family
Verify the family quota has enough capacity: Quota Value > Usage + Required vCPUs
To increase your quota, go to AWS Service Quotas console:
1. Open Service Quotas console
2. Select Amazon EC2
3. Find the quota matching your instance type (e.g., "Running On-Demand Standard (A, C, D, H, I, M, R, T, Z) instances")
4. Click the quota name
5. Click Request quota increase
6. Enter the new desired value
7. Click Request
AWS typically approves vCPU increases within hours. You can also request via AWS Support Center for expedited processing.
Quota codes for CLI:
- Standard instances: L-1216C47A
- All Standard instances: L-34B43A08
Using AWS CLI:
aws service-quotas request-service-quota-increase \
--service-code ec2 \
--quota-code L-1216C47A \
--desired-value 20While waiting for quota increase approval, use a smaller instance type that fits within your current quota:
# Current failing configuration (requires 4 vCPUs)
resource "aws_instance" "example" {
instance_type = "m5.xlarge" # 4 vCPUs
}
# Workaround: use smaller type (requires 1 vCPU)
resource "aws_instance" "example" {
instance_type = "t3.micro" # 1 vCPU
}This lets you continue development. Once your quota increase is approved, change back to the desired instance type.
AWS quotas are regional. If you need the instance immediately, try launching in a different region:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "us-east-1" # Try different region
}
resource "aws_instance" "example" {
instance_type = "m5.xlarge"
# ... rest of config
}Check your quota in the target region first via Service Quotas console.
If Spot instances meet your needs, they have a separate quota that may be higher:
resource "aws_instance" "example" {
instance_type = "m5.xlarge"
instance_market_options {
market_type = "spot"
}
spot_type = "one-time"
}Note: Spot instances can be interrupted by AWS and are cheaper but less reliable. They're ideal for fault-tolerant, non-critical workloads.
Once AWS approves your quota increase:
1. Verify the new quota value in Service Quotas console
2. Check that your Terraform configuration is correct:
resource "aws_instance" "example" {
instance_type = "m5.xlarge"
# ... other configuration
}3. Run Terraform again:
terraform plan
terraform applyIf the instance launches successfully, confirm with AWS CLI:
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running"Advanced notes
Account-level vs Regional quotas:
vCPU quotas are regional. A new AWS account typically has 5 vCPUs for On-Demand Standard instances per region. This is different from other quotas (security groups, VPCs) that may be global.
Instance family grouping:
AWS groups instance types by family. Some important families:
- Standard: A, C, D, H, I, M, R, T, Z - general purpose, web servers, small databases
- Compute optimized: C-series - high-performance computing
- GPU: g3, p3, p4 - machine learning, graphics
- Memory optimized: r5, r6, x1, z1 - databases, caches
Each family may have its own quota. Request increases for your specific family.
Quota increase timelines:
- Most increases are approved within 2-4 hours
- Large increases (100+ vCPUs) may require AWS support review (1-2 days)
- For time-sensitive workloads, contact AWS Support for expedited approval
Cost implications:
Larger instance types cost more per hour. Plan your quota increase based on actual needs, not just your infrastructure requirements.
Terraform best practices:
- Use terraform plan before apply to verify all resources
- Set up separate AWS accounts/regions for dev, staging, and production to avoid quota conflicts
- Use tags to track which instances consume your quota
Frequently asked questions
- What does "VcpuLimitExceeded" mean?
- AWS uses a quota system to manage resource capacity across regions and instance types. Each AWS account has a default vCPU limit (typically 5 vCPUs for On-Demand Standard instances). When Terraform attempts to create an EC2 instance, AWS checks if the instance type's vCPUs would exceed your account's remaining quota.
- How do I fix "VcpuLimitExceeded"?
- You've reached your AWS account's vCPU quota limit for EC2 instances. AWS enforces soft limits on the number of vCPUs you can use in a region. This error occurs when trying to launch an instance that would exceed your current quota.
- What causes "VcpuLimitExceeded"?
- Current vCPU quota is too low for the instance type you're trying to launch Default AWS account quota for Standard instances is exhausted by other running instances Spot instance quotas and On-Demand quotas are separate; you may have confused them
- Is the "VcpuLimitExceeded" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- 📚Terraform Official Documentation
- 📖AWS: EC2 resource limits and quotas(Official Docs)
- 📖AWS Service Quotas: User guide and quota management(Official Docs)
- 📖AWS CLI: request-service-quota-increase command reference(Official Docs)