Skip to content
Latchkey

Terraform "timeout while waiting for state to become available" in CI

The provider creates a resource and then polls until it reports a ready state (e.g. EC2 "available", RDS "available"). If it does not reach that state before the timeout, the operation errors.

What this error means

apply fails with "timeout while waiting for state to become available" or "Expected state available". The resource may still be provisioning; sometimes it is a slow region/AZ, sometimes a genuinely stuck resource.

terraform
Error: waiting for EC2 Instance (i-0abc123) to become available:
timeout while waiting for state to become 'running, available', last state:
'pending', timeout: 10m0s

  with aws_instance.app,
  on main.tf line 12, in resource "aws_instance" "app":

Common causes

Resource genuinely slow to provision

Large or dependency-heavy resources (RDS, NAT gateways, big instances) can exceed the default wait window under load.

Resource stuck or misconfigured

A failed user-data script, an unsatisfiable dependency, or capacity issues can keep a resource from ever reaching the ready state.

How to fix it

Raise the create timeout, then retry

Extend the resource timeouts block to fit realistic provisioning time and re-run.

main.tf
resource "aws_instance" "app" {
  # ...
  timeouts {
    create = "20m"
  }
}

Rule out a stuck resource

  1. Check the resource state in the console/CLI; if it is failing (not just slow), fix the root cause.
  2. Inspect user-data/bootstrap logs for instances that never become ready.
  3. Confirm capacity and dependency availability in the target AZ.

How to prevent it

  • Set realistic timeouts on slow-provisioning resources.
  • Validate bootstrap scripts so instances reliably reach ready state.
  • Run apply on a platform that auto-retries transient provisioning timeouts.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →