Skip to content
Latchkey

Terraform "context deadline exceeded" during plan or apply in CI

A "context deadline exceeded" means a request the provider made did not complete before its deadline. It is a timeout at the API or network layer, distinct from a Terraform resource timeout, and is often transient.

What this error means

plan or apply fails with "context deadline exceeded" wrapped in a provider or backend error, sometimes alongside "Client.Timeout" or a connection reset.

Terraform
Error: error reading S3 bucket: RequestError: send request failed
caused by: Get "https://...": context deadline exceeded (Client.Timeout exceeded
while awaiting headers)

Common causes

Transient slow or unreachable API endpoint

A momentary network slowdown or an overloaded provider endpoint makes a single request exceed its deadline.

A resource that takes longer than its timeout

Provisioning that runs past the resource's configured timeout surfaces a deadline-exceeded during the wait.

How to fix it

Retry the operation

  1. Re-run plan or apply, since a deadline-exceeded is frequently transient.
  2. If it recurs at the same step, raise the relevant resource timeout.
  3. Check runner network egress to the provider endpoint.
Terminal
terraform apply

Extend a resource timeout for slow provisioning

For resources that legitimately take long, raise the create/update timeout in the resource block.

main.tf
resource "aws_db_instance" "this" {
  # ...
  timeouts {
    create = "60m"
  }
}

How to prevent it

  • Set realistic timeouts blocks for slow-provisioning resources.
  • Ensure runner network access to all required cloud endpoints.
  • Retry idempotent plan/apply on transient deadline errors.

Related guides

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