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
- List recent operations to see whether it completed after Terraform stopped waiting.
- If it is DONE, a refresh-only plan reconciles state.
- 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
timeoutsfor 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
Terraform AWS provider "timeout while waiting for state to become available" in CIFix Terraform AWS provider "error waiting for ... : timeout while waiting for state to become 'available'" in…
Terraform Google provider "Error 403: Quota exceeded" in CIFix Terraform Google provider "googleapi: Error 403: Quota ... exceeded" / RESOURCE_EXHAUSTED in CI - the req…
Terraform Google provider "API not enabled / has not been used" in CIFix Terraform Google provider "Error 403: ... API has not been used in project ... before or it is disabled"…