You've reached the AWS NAT gateway quota (default 5 per Availability Zone). This occurs when provisioning infrastructure with Terraform and your account has too many NAT gateways in the same AZ or Deleting status gateways haven't fully cleaned up yet.
AWS enforces a quota on the number of NAT gateways you can create in each Availability Zone. The default limit is 5 NAT gateways per AZ. This prevents resource exhaustion and helps manage costs. A NAT gateway in Pending, Available, or Deleting state counts against this limit. When Terraform tries to create a NAT gateway and this quota is exceeded, AWS rejects the operation with the NatGatewayLimitExceeded error.
Log into the AWS Console and navigate to the VPC service. Click on NAT gateways to see all gateways in your region. Count how many exist in each Availability Zone and note which ones are in Deleting status. This tells you how much quota you're consuming.
Alternatively, use the AWS CLI:
aws ec2 describe-nat-gateways --region us-east-1 \
--query 'NatGateways[*].[NatGatewayId,State,SubnetId]' \
--output tableIf you see NAT gateways in Deleting state, these still count against your quota. Wait 2-5 minutes for them to transition to Deleted state, then they won't consume quota. Verify completion with:
aws ec2 describe-nat-gateways --region us-east-1 \
--filter "Name=state,Values=deleted" \
--query 'NatGateways[*].NatGatewayId'If you have NAT gateways that are no longer needed, delete them to free up quota. First verify nothing depends on them by checking route tables:
aws ec2 describe-route-tables --region us-east-1 \
--query "RouteTables[?Routes[?NatGatewayId=='nat-12345678']].RouteTableId"Then delete via the console or CLI:
aws ec2 delete-nat-gateway --nat-gateway-id nat-12345678 --region us-east-1Review your Terraform code to ensure you're not creating more NAT gateways than necessary. Use module options to limit creation:
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
# Option 1: Single NAT gateway for entire VPC (cost-effective but less resilient)
single_nat_gateway = true
# Option 2: One NAT gateway per availability zone (recommended)
one_nat_gateway_per_az = true
# Avoid: Creating one NAT gateway per private subnet
# This consumes quota quickly and is unnecessary
}If you legitimately need more than 5 NAT gateways per AZ:
1. Go to the AWS Service Quotas console: https://console.aws.amazon.com/servicequotas
2. Search for "NAT gateways per Availability Zone"
3. Click on the quota and select "Request quota increase"
4. Enter the desired value (AWS typically approves reasonable increases)
5. Submit the request and wait for approval
Alternatively, use the CLI:
aws service-quotas request-service-quota-increase \
--service-code vpc \
--quota-code L-FE5A380F \
--desired-value 10 \
--region us-east-1Once you've freed up quota or received approval for an increase, retry your Terraform deployment:
terraform plan
terraform applyIf using destroy and recreate, wait for all resources to fully delete before reapplying:
terraform destroy
# Wait 2-5 minutes
terraform applyNAT gateway limits are per Availability Zone, not per region or account. You can have 5 in us-east-1a, 5 in us-east-1b, and 5 in us-east-1c simultaneously. Regional NAT gateways (in preview) may have different quota behavior - check AWS documentation if you're using them. If you have cross-account infrastructure, ensure NAT gateways are distributed across accounts to avoid hitting a single account's quota. For very high availability needs with multiple NAT gateways, consider using Gateway Load Balancer instead of managing many separate NAT gateways.
Error: Error installing helm release: cannot re-use a name that is still in use
How to fix "release name in use" error in Terraform with Helm
Error: Error creating GKE Cluster: BadRequest
BadRequest error creating GKE cluster in Terraform
Error: External program failed to produce valid JSON
External program failed to produce valid JSON
Error: Unsupported argument in child module call
How to fix "Unsupported argument in child module call" in Terraform
Error: network is unreachable
How to fix "network is unreachable" in Terraform