Terraform & IaC Errors
State locks, provider auth, drift, dependency cycles and plan-time unknowns.
Understanding Terraform errors
Terraform errors are mostly state errors. A stuck lock, a resource that exists in the cloud but not in state, or a value that cannot be known until apply time all trace back to how Terraform models the world. The for_each-on-unknown-values error is the most common conceptual stumble: Terraform must know the keys of a map at plan time, even if the values are unknown.
How to debug Terraform errors
- For a stuck lock, find out who holds it before forcing anything.
terraform force-unlock <id>is safe only when you are certain no apply is running. - Use
terraform state listandterraform state show <addr>to see what Terraform believes exists, andterraform importto adopt resources created outside it. - Set
TF_LOG=DEBUGandTF_LOG_PATH=tf.logfor provider-level detail on authentication and API errors. - For
for_eacherrors, restructure so keys come from static values or from variables, not from attributes of resources that do not yet exist. Use-targetfor a staged apply as a last resort. - Run
terraform plan -refresh-onlyto see drift explicitly before applying anything unexpected.
Tools worth reaching for
terraform state list/showTF_LOG=DEBUGterraform plan -refresh-onlyterraform graphtflint / checkov
All 18 Terraform errors
- OpenTofu: state is encrypted but no key provider is configured NewOpenTofu can encrypt state and plan files at rest. Once a state has been written encrypted, every later run needs the…
- Terraform: An argument named "x" is not expected here NewThe configuration uses an argument the provider schema does not have. Usually the provider is older than the…
- Terraform: Cannot import resource - not foundThe resource ID provided to terraform import does not match any existing resource in the cloud provider.
- Terraform: Cycle (resources depend on each other) NewTerraform builds a dependency graph from references and cannot order a cycle. Two resources referencing each other's…
- Terraform: Cycle dependency detectedCircular dependency in resource definitions, resources depend on each other in a loop.
- Terraform: Failed to install provider, could not query provider registry Newterraform init could not fetch a provider. Beyond plain network failure the frequent causes are a source address that…
- Terraform: for_each value depends on resource attributes that cannot be determinedA for_each or count expression depends on a value that is not known until apply time. Terraform needs to know the…
- Terraform: Inconsistent dependency lock file NewThe provider versions or platform hashes recorded in .terraform.lock.hcl do not cover what this run needs, commonly…
- Terraform: Instance cannot be destroyed (prevent_destroy) NewThe resource carries a lifecycle block with prevent_destroy set, and the plan would destroy it. Terraform refuses at…
- Terraform: Invalid count argument (value depends on resource attributes) NewTerraform must know how many instances a resource has before it can build the plan graph. A count derived from an…
- Terraform: Plugin crashedA Terraform provider plugin crashed during execution. Usually a bug in the provider or a version incompatibility.
- Terraform: Provider authentication failedCannot authenticate with cloud provider. Missing credentials, expired tokens, or incorrect configuration.
- Terraform: provider checksum list has no SHA-256 hash NewThe dependency lock file records provider hashes per platform. When it was generated on one OS and CI runs on another…
- Terraform: Provider not foundRequired provider is not installed or version constraint cannot be satisfied.
- Terraform: Provider produced inconsistent final plan NewThe provider returned a value after apply that differs from what it promised at plan time. This is a provider bug or a…
- Terraform: Remote backend configuration errorCannot access remote backend for state storage. S3 bucket missing, permission denied, or backend misconfigured.
- Terraform: Resource already existsTrying to create resource that already exists in cloud provider. Resource created outside Terraform or import needed.
- Terraform: State lockedState file is locked by another Terraform operation. Previous operation didn't complete or crashed.
Other categories
- AI 35Rate limits, context windows, GPU memory and model-serving failures.
- Ansible 10Unreachable hosts, become passwords, undefined variables and Jinja2 failures.
- API 14Auth headers, payload limits, versioning, idempotency and webhook signatures.
- Apple 10Command line tools, dyld, Homebrew permissions, notarisation and Keychain.
- Auth 11OIDC, SAML, Auth0, Okta, Keycloak, passkeys and MFA failures.
- BigData 11Spark, Kafka, Airflow, Snowflake, Flink and Databricks failures.
- C# 12NuGet restore, null references, EF Core migrations, async deadlocks and Blazor…
- C++ 11Segfaults, linker errors, memory corruption and template deduction failures.
- Caching 10Cache stampedes, stale content, Varnish and CloudFront failures.
- CI/CD 18GitHub Actions, GitLab CI, Jenkins, CircleCI: permissions, runners and…
- Client 21CORS, mixed content, module resolution, memory limits and framework runtime…
- Cloud 25IAM permissions, quotas, service limits and credential failures.
- Dart 10Null safety, pub version solving and build toolchain problems.
- Database 41Connections, deadlocks, constraints, replication and memory limits.
- DNS 10NXDOMAIN, SERVFAIL, timeouts, propagation and delegation problems.
- Docker 27Daemon connectivity, disk space, image pulls, ports and architecture mismatches.
- Elixir 9GenServer timeouts, supervision failures and Mix compilation problems.
- Email 8Delivery failures, relay denial, authentication, SPF, DKIM and DMARC.
- Frontend 23Hydration mismatches, bundler resolution, layout shift and font loading.
- Git 20Merge conflicts, rejected pushes, detached HEAD, LFS and repository corruption.
- Go 19Nil map assignment, concurrent map access, context cancellation and deadlocks.
- GraphQL 13Validation, depth limits, N+1 queries and fragment problems.
- gRPC 10Status codes, deadlines, message limits, TLS and HTTP/2 transport failures.
- HTTP 494xx client errors, 5xx server errors, redirects, headers and protocol problems.
- ICMP 23Destination unreachable, time exceeded, fragmentation needed and redirects.
- Ingress 8404 default backend, missing TLS secrets, IngressClass and path matching.
- Java 19Class loading, dependency resolution, connection pools and JVM version…
- JavaScript 42npm resolution, async pitfalls, hydration, memory limits and runtime type…
- Kubernetes 34CrashLoopBackOff, ImagePullBackOff, OOMKilled, RBAC, scheduling and storage.
- Logging 9Log4j, Logback, Fluentd, Logstash and CloudWatch ingestion problems.
- MessageQueue 14Kafka, RabbitMQ, SQS, NATS and Celery: lag, rebalancing and poison messages.
- Mobile 17Gradle, CocoaPods, Xcode signing, Metro bundler and toolchain mismatches.
- Monitoring 12Prometheus scrapes, Grafana data sources, OpenTelemetry exporters and agent…
- Network 35Refused connections, timeouts, resets, MTU problems and port exhaustion.
- Performance 6GC pauses, thread pool starvation and event loop blocking.
- PHP 11Memory limits, execution timeouts, autoloading, Composer and PDO connections.
- Proxy 17nginx, Envoy, HAProxy, Traefik, Caddy and Cloudflare upstream failures.
- Python 35Imports, virtual environments, encoding, concurrency and dependency conflicts.
- Regex 8Catastrophic backtracking, back references, escaping and engine differences.
- Ruby 11Bundler, migrations, native extensions, encoding and asset compilation.
- Rust 19Borrow checker, ownership moves, trait bounds and lifetime mismatches.
- Scala 6Dependency resolution, binary compatibility and type inference failures.
- Security 25JWT validation, CSRF, OAuth grants, SELinux, SSH host keys and CSP.
- Serverless 11Lambda timeouts, package size limits, VPC networking and cold starts.
- Shell 13Command not found, permissions, quoting, expansion and Makefile syntax.
- Storage 13S3 permissions, NFS mounts, quotas, signed URLs and volume attachment.
- Svelte 10Store subscriptions, load functions and server/client boundaries.
- System 26Disk space, systemd units, file descriptors, OOM killer and scheduled jobs.
- Testing 18Jest, pytest, JUnit, Cypress and Playwright: fixtures, snapshots and timeouts.
- TLS 24Untrusted authorities, expiry, hostname mismatch, chains and cipher negotiation.
- TypeScript 19Assignability, missing declarations, strict null checks and generic constraints.
- Virtualization 8VirtualBox, VMware, Hyper-V, WSL, KVM and hypervisor conflicts.
- Web3 7Gas estimation, nonce management and reverted transactions.
- WebAssembly 7Compile errors, memory bounds and host binding mismatches.
- WebServer 10nginx, Apache, IIS and Caddy: binding, permissions, rewrites and TLS.
- Windows 10Installer failures, missing runtimes, update errors and permission problems.