Skip to content
Latchkey

Terraform Google provider "Error waiting for ... operation" timeout in CI

The Google provider started a long-running operation, then polled until it should complete, but the timeout elapsed first. The operation may still be running in GCP; Terraform just stopped waiting.

What this error means

terraform apply fails with "Error waiting for Creating <Resource>: timeout while waiting for state to become 'DONE'" or "context deadline exceeded" for a GKE cluster, instance, or SQL instance.

Terraform
Error: Error waiting for creating Network: timeout while waiting for state
to become 'DONE' (last state: 'RUNNING', timeout: 4m0s)

Common causes

The operation is slower than the default timeout

GKE clusters, Cloud SQL instances, and similar resources can take longer to reach DONE than the provider's default wait.

The operation is stuck or failed

A backend failure leaves the operation not progressing, so the wait runs out without a DONE state.

How to fix it

Raise the resource timeout

Give slow resources more time with a timeouts block.

main.tf
resource "google_container_cluster" "primary" {
  # ...
  timeouts {
    create = "30m"
  }
}

Check the operation status in GCP

  1. List recent operations to see whether it completed after Terraform stopped waiting.
  2. If it is DONE, a refresh-only plan reconciles state.
  3. If it failed, read the operation error and fix the cause.
Terminal
gcloud compute operations list --filter="status!=DONE"

How to prevent it

  • Set realistic timeouts for slow GCP resources.
  • Reconcile state with a refresh-only plan after a wait timeout.
  • Inspect the operation to tell a slow create from a failed one.

Related guides

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