OpenTofu AI Prompts
25 free, production-ready OpenTofu AI prompts — copy-paste ready for ChatGPT, Claude, or Cursor. Every prompt ships with fill-in placeholders, a worked example, and production-safety notes, so you get a usable answer on the first try.
- OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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 - OpenTofu 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
About these OpenTofu AI prompts
This is a free, curated collection of OpenTofu AI prompts for DevOps and platform engineers — prompt templates that turn Claude, ChatGPT, or Cursor into a focused OpenTofu assistant. Instead of re-explaining your setup every time, each prompt has fill-in placeholders, a realistic worked example, and explicit safety and back-out notes, so it's safe to use against production OpenTofu.
Browse all 25 above, or explore the wider OpenTofu prompts and troubleshooting guides, the full DevOps AI prompt library, and run or compare any prompt live in the Prompt Workspace. Hit a production issue instead? Try the free Incident Assistant.