AI for OpenTofu
Write and troubleshoot OpenTofu with AI — the open-source Terraform fork: HCL modules, state and backends, providers, plan/apply, drift, testing, and migrating from Terraform.
25 copy-paste prompts · 25 in-depth guides Jump to prompts Jump to guides
Prompts
- Intermediate
OpenTofu azurerm Backend Configuration Prompt
Configure a secure OpenTofu state backend on Azure Blob Storage with blob versioning, lease-based locking, and RBAC-scoped access.
- Claude
- ChatGPT
Open prompt - Advanced
OpenTofu CI/CD Pipeline Design Prompt
Design a safe OpenTofu CI/CD pipeline — fmt/validate, plan-on-PR with a saved plan artifact, gated apply-on-merge, locking, and least-privilege cloud auth.
- Claude
- ChatGPT
Open prompt - Intermediate
OpenTofu Cost Review Prompt
Estimate and review the cost impact of an OpenTofu change from the plan before it ships, catching expensive resources and runaway for_each fan-out.
- Claude
- ChatGPT
Open prompt - Intermediate
OpenTofu Dependency Lock File Management Prompt
Manage the OpenTofu dependency lock file so provider hashes are complete across every CI and developer platform, and upgrades are auditable in review.
- Claude
- ChatGPT
Open prompt - Advanced
OpenTofu Drift Detection & Remediation Prompt
Detect configuration drift between OpenTofu state and live infrastructure, classify each drift, and choose the safest remediation — reconcile, import, or accept.
- Claude
- ChatGPT
Open prompt - Intermediate
OpenTofu for_each & dynamic Block Patterns Prompt
Replace copy-pasted resources with clean for_each and dynamic patterns in OpenTofu, using stable keys so adding one item never churns the others.
- Claude
- ChatGPT
- Cursor
Open prompt - Intermediate
OpenTofu GCS Backend Configuration Prompt
Configure a secure, versioned Google Cloud Storage backend for OpenTofu state with object versioning, CMEK encryption, and least-privilege service accounts.
- Claude
- ChatGPT
Open prompt - Advanced
OpenTofu HTTP Backend Configuration Prompt
Wire OpenTofu to an HTTP state backend (e.g. GitLab-managed or a self-hosted REST state service) with locking, auth, and TLS handled correctly.
- Claude
- ChatGPT
Open prompt - Advanced
OpenTofu Integration Testing in Ephemeral Environments Prompt
Design end-to-end integration tests that provision real infrastructure in a throwaway environment using tofu test apply runs, assert on live outputs, and always clean up.
- Claude
- ChatGPT
Open prompt - Intermediate
OpenTofu Module Design Patterns Prompt
Design a reusable OpenTofu module with a clean input/output contract, sane defaults, validation, and composition boundaries that scale across teams.
- Claude
- ChatGPT
- Cursor
Open prompt - Advanced
OpenTofu moved & removed Block Refactor Prompt
Refactor OpenTofu resource addresses safely using moved and removed blocks so renames and restructures never trigger a destroy-and-recreate.
- Claude
- ChatGPT
- Cursor
Open prompt - Intermediate
OpenTofu Multi-Environment Layout Prompt
Design a repository and state layout for dev/staging/prod in OpenTofu that maximizes shared modules while keeping environments independently applied and blast-radius bounded.
- Claude
- ChatGPT
Open prompt - Advanced
OpenTofu Override & .tofu Files Prompt
Use OpenTofu override files and .tofu file extensions deliberately — for local dev overrides and OpenTofu-specific config — without hiding surprises from the next engineer.
- Claude
- ChatGPT
Open prompt - Advanced
OpenTofu Plan Diff Debugging Prompt
Explain why a `tofu plan` shows an unexpected diff or perpetual change, and pin down the exact attribute and cause behind a forced replacement.
- Claude
- ChatGPT
Open prompt - Intermediate
OpenTofu Plan Review Prompt
Turn a `tofu plan` into a structured risk review that flags replacements, destroys, and sensitive changes before anyone approves an apply.
- Claude
- ChatGPT
- Cursor
Open prompt - Advanced
OpenTofu Policy-as-Code Prompt
Add automated policy enforcement to an OpenTofu pipeline using OPA/Conftest or Sentinel-style checks against the plan JSON, gating risky changes before apply.
- Claude
- ChatGPT
Open prompt - Intermediate
OpenTofu Provider Version Pinning Prompt
Set correct version constraints for OpenTofu itself and every provider so builds are reproducible, upgrades are deliberate, and shared modules stay compatible.
- Claude
- ChatGPT
Open prompt - Intermediate
OpenTofu Registry & Module Sourcing Prompt
Choose and pin module sources correctly in OpenTofu — the OpenTofu Registry, Git, or a private registry — with version constraints that stay reproducible and auditable.
- Claude
- ChatGPT
Open prompt - Advanced
OpenTofu Remote State Data Sources Prompt
Design how one OpenTofu stack consumes another's outputs via terraform_remote_state versus native provider data sources, minimizing coupling and blast radius.
- Claude
- ChatGPT
Open prompt - Intermediate
OpenTofu S3 Backend Configuration Prompt
Stand up a secure, locked, versioned S3 backend for OpenTofu state — encryption, native S3 locking, IAM scoping, and state-path layout.
- Claude
- ChatGPT
Open prompt - Advanced
OpenTofu Secrets Handling Prompt
Keep secrets out of OpenTofu code and state — sourcing from a secrets manager, marking values sensitive, and pairing with native state encryption so nothing leaks.
- Claude
- ChatGPT
Open prompt - Advanced
OpenTofu State Import & Migration Prompt
Bring existing, unmanaged infrastructure under OpenTofu safely using import blocks and generated config, or move resources between state files without recreating them.
- Claude
- ChatGPT
Open prompt - Advanced
OpenTofu Teardown & Rollback Safety Prompt
Plan a safe teardown or rollback of OpenTofu-managed infrastructure with data protection, dependency ordering, and a tested recovery path before you destroy anything.
- Claude
- ChatGPT
Open prompt - Intermediate
OpenTofu Version Upgrade Prompt
Plan a safe upgrade of the OpenTofu CLI across a fleet — reading the changelog for state-format and breaking changes, staging the rollout, and pinning versions in CI.
- Claude
- ChatGPT
Open prompt - Intermediate
OpenTofu Workspace Strategy Prompt
Decide when OpenTofu workspaces are the right tool versus directory-per-environment, and design a workspace layout that will not surprise you at apply time.
- Claude
- ChatGPT
Open prompt
Guides
- · 8 min read
OpenTofu Error: 'Backend configuration changed' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Backend configuration changed' with tofu init -migrate-state or -reconfigure after editing the backend block.
Read guide - · 8 min read
OpenTofu Error: 'Cycle' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Cycle' dependency loops from circular resource references, mutual module dependencies, and depends_on chains.
Read guide - · 8 min read
OpenTofu Error: 'Duplicate resource configuration' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Duplicate resource configuration' from repeated resource addresses across files, bad copy-paste, or count/for_each conflicts.
Read guide - · 9 min read
OpenTofu Error: 'Failed to query available provider packages' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Failed to query available provider packages' from registry outages, air-gapped networks, bad source addresses, or proxy blocks.
Read guide - · 8 min read
OpenTofu Error: 'Inconsistent dependency lock file' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Inconsistent dependency lock file' by running tofu init -upgrade and recording every platform hash in .terraform.lock.hcl.
Read guide - · 8 min read
OpenTofu Error: 'Invalid count argument' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Invalid count argument' when count depends on values not known until apply, using -target, for_each, or static inputs.
Read guide - · 8 min read
OpenTofu Error: 'Invalid encryption configuration' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Invalid encryption configuration' from malformed encryption blocks, undefined key providers, or bad method references.
Read guide - · 8 min read
OpenTofu Error: 'Invalid function argument' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Invalid function argument' from wrong types, null values, or malformed inputs passed to built-in functions.
Read guide - · 8 min read
OpenTofu Error: 'Invalid legacy provider address' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Invalid legacy provider address' after migrating state from Terraform by running tofu state replace-provider.
Read guide - · 8 min read
OpenTofu Error: 'Invalid provider configuration' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Invalid provider configuration' from missing credentials, bad region/endpoint values, or wrong provider alias wiring.
Read guide - · 8 min read
OpenTofu Error: 'Error loading state: AccessDenied' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error loading state: ... AccessDenied' from missing IAM permissions, wrong bucket/region, expired credentials, or KMS denials.
Read guide - · 8 min read
OpenTofu Error: 'Missing required argument' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Missing required argument' by supplying required resource attributes, module inputs, or nested block fields.
Read guide - · 8 min read
OpenTofu Error: 'Module not installed' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Module not installed' by running tofu init to download modules, and persisting .terraform across CI steps.
Read guide - · 8 min read
OpenTofu Error: 'Objects have changed outside of OpenTofu' — Cause, Fix, and Troubleshooting Guide
Understand OpenTofu 'Note: Objects have changed outside of OpenTofu' drift, reconcile it with refresh, imports, and ignore_changes.
Read guide - · 8 min read
OpenTofu Error: 'Provider configuration not present' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Provider configuration not present' when removing resources whose provider block is gone, using tofu state rm or restoring the provider.
Read guide - · 8 min read
OpenTofu Error: 'Provider does not support resource type' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: ... provider does not support resource type' from typos, missing/old providers, or wrong provider source addresses.
Read guide - · 9 min read
OpenTofu Error: 'Provider produced inconsistent final plan' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Provider produced inconsistent final plan' caused by provider bugs, computed attributes, and version mismatches during tofu apply.
Read guide - · 8 min read
OpenTofu Error: 'Reference to undeclared resource' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Reference to undeclared resource' from typos, missing resource blocks, wrong module scope, or renamed resources.
Read guide - · 8 min read
OpenTofu Error: 'Resource already exists' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: ... already exists' on apply by importing the existing object into state with tofu import or an import block.
Read guide - · 9 min read
OpenTofu Error: 'decryption failed' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu state encryption 'Error: decryption failed' from wrong/rotated keys, missing key providers, or mismatched encryption config.
Read guide - · 9 min read
OpenTofu Error: 'Error acquiring the state lock' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Error acquiring the state lock' from stale DynamoDB/Postgres locks, crashed runs, or concurrent tofu apply in CI.
Read guide - · 8 min read
OpenTofu Error: 'state snapshot was created by a newer version' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: state snapshot was created by ... a newer version' by upgrading tofu to match the version that last wrote the state.
Read guide - · 8 min read
OpenTofu Error: 'Unsuitable value type' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Unsuitable value type' from variable type mismatches, wrong collection types, or values that can't convert to the expected type.
Read guide - · 8 min read
OpenTofu Error: 'Unsupported argument' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Unsupported argument' from typos, deprecated/removed provider fields, wrong nesting, or provider version drift.
Read guide - · 8 min read
OpenTofu Error: 'Unsupported OpenTofu Core version' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Unsupported OpenTofu Core version' from required_version constraints that don't match the installed tofu binary.
Read guide