TerraformPilot

DevOps

Fix Terraform Error - Timeout While Waiting for State

Fix timeout errors in Terraform when resources take too long to create. Increase timeouts, handle slow cloud operations, and debug hanging applies.

LLuca Berton1 min read

Quick Answer

#

The resource didn't reach a ready state within Terraform's timeout period. Add a timeouts block with longer values, or fix the underlying issue (misconfigured networking, missing IAM permissions, or unhealthy resource).

The Error

#
Error: timeout while waiting for state to become 'ACTIVE' 
(last state: 'CREATING', timeout: 10m0s)
Error: Error waiting for RDS instance to be available: timeout 
while waiting for state to become 'available'

What Causes This

#
  • Resource genuinely slow — RDS instances take 10-20 minutes, EKS clusters 15-20 minutes
  • Misconfigured networking — no internet access for resources that need it (NAT gateway, VPC endpoints)
  • Insufficient permissions — resource created but can't complete setup
  • Resource stuck — health check failing, dependency missing

How to Fix It

#

Solution 1: Increase Timeouts

#
resource "aws_db_instance" "main" {
  identifier     = "production-db"
  engine         = "postgres"
  instance_class = "db.r6g.large"
 
  timeouts {
    create = "60m"  # RDS can take 20+ minutes
    update = "60m"
    delete = "60m"
  }
}
 
resource "aws_eks_cluster" "main" {
  name     = "production"
  role_arn = aws_iam_role.eks.arn
 
  timeouts {
    create = "30m"  # EKS clusters take 15-20 minutes
    update = "30m"
    delete = "30m"
  }
}
 
resource "aws_elasticache_cluster" "main" {
  cluster_id = "cache"
  engine     = "redis"
 
  timeouts {
    create = "30m"
    delete = "30m"
  }
}

Solution 2: Fix Networking

#
# Resources in private subnets need NAT for internet access
resource "aws_nat_gateway" "main" {
  allocation_id = aws_eip.nat.id
  subnet_id     = aws_subnet.public.id
}
 
resource "aws_route" "private_nat" {
  route_table_id         = aws_route_table.private.id
  destination_cidr_block = "0.0.0.0/0"
  nat_gateway_id         = aws_nat_gateway.main.id
}

Solution 3: Check Resource Status in Console

#
# Check what's happening with the resource
aws rds describe-db-instances --db-instance-identifier production-db \
  --query 'DBInstances[0].DBInstanceStatus'
 
# Check EKS cluster status
aws eks describe-cluster --name production \
  --query 'cluster.status'

Typical Creation Times

#
ResourceTypical TimeRecommended Timeout
EC2 instance1-3 min10m (default)
RDS instance10-20 min60m
EKS cluster15-20 min30m
ElastiCache5-15 min30m
NAT Gateway2-5 min10m
CloudFront15-30 min60m
Redshift cluster10-20 min60m

Troubleshooting Checklist

#
  1. ✅ Is the timeout long enough for this resource type?
  2. ✅ Check the resource status in the cloud console — is it stuck or still creating?
  3. ✅ Does the resource have internet/network access it needs?
  4. ✅ Are IAM permissions correct?
  5. ✅ Is there a dependency that isn't ready?
#

Conclusion

#

Timeouts usually mean the resource is slow (normal for RDS, EKS, CloudFront) or something is blocking it (networking, permissions). Increase the timeouts block first, then check the resource status in the cloud console to understand if it's still creating or stuck.

#Terraform#Troubleshooting#DevOps#Error Fix#Infrastructure as Code

Share this article