Terraform AI Prompts
146 free, production-ready Terraform 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.
- Terraform Intermediate
Dangerous Terraform Changes Review Prompt
Scan a `terraform plan` output for changes that will silently destroy data, cause outages, or trigger irreversible mutations.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Module Review Prompt
Get a senior-engineer review of a Terraform module — variable hygiene, state safety, security defaults, drift resistance.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Intermediate
Terraform State Backend Design Prompt
Design Terraform state backend — S3+DynamoDB, GCS, Azure Blob, encryption, locking, versioning, cross-account access.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Blue Green Deployment Pattern Prompt
Implement blue/green infrastructure deployments in Terraform with parallel resource sets, create_before_destroy, and weighted DNS or target-group cutover with rollback.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Checkov Custom Policy Authoring Prompt
Write custom Checkov policies for Terraform — Python checks extending BaseResourceCheck and YAML-based policies, a .checkov.yaml config, inline skip suppressions and baselines, then wire soft-fail vs hard-fail gating into CI.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Cloudflare DNS Module Design Prompt
Design a Cloudflare provider module that manages a zone and many DNS records via a for_each map while guarding apex and NS records from accidental deletion.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Datadog Monitors as Code Prompt
Design a reusable Terraform module that manages Datadog monitors, dashboards, and SLOs from a single typed map without triggering alert storms.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Ephemeral Preview Environments Prompt
Design per-PR ephemeral preview environments with Terraform — unique naming/tagging, TTL auto-destroy in CI, DNS/subdomain per env, cost caps, and safe teardown on PR close without nuking the wrong workspace.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform GitHub Org Management Module Prompt
Manage a GitHub organization as code with repos, teams, memberships, and branch protection via for_each, importing existing repos safely.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
HCP Terraform Agent Pool Design Prompt
Design HCP Terraform (Terraform Cloud) agent pools for private-network runs — tfe_agent_pool, allowed-workspaces scoping, agent tokens, self-hosted agent deployment, agent execution mode, scaling, and hardening the agent hosts.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform TFLint Custom Ruleset Authoring Prompt
Author a custom TFLint ruleset — .tflint.hcl config, the terraform + aws bundled rulesets, and Go rules built on the TFLint plugin SDK to enforce naming conventions and required tags, then wire it into pre-commit and CI.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Vault Provider Secrets Integration Prompt
Inject HashiCorp Vault secrets into Terraform via data sources and ephemeral resources without persisting plaintext to state.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform jsonencode Policy Rendering Review Prompt
Review IAM/resource policies built with jsonencode and templatefile in Terraform for correctness, injection risk, and plan-time diff noise.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform replace_triggered_by Design Review Prompt
Design and audit lifecycle replace_triggered_by rules so intentional replacements fire correctly without causing surprise destroy/recreate cascades.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Provider Rate-Limit & Throttling Strategy Prompt
Diagnose and tune Terraform applies that intermittently fail with cloud provider API throttling (429/Rate exceeded) on large state or high-concurrency runs.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Backend State Lock Timeout Tuning Prompt
Tune Terraform state locking — lock-timeout, DynamoDB/backend contention, CI concurrency, and safe recovery from stuck locks.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform External & HTTP Data Source Security Review Prompt
Review Terraform external, http, and local-exec data sources for injection, secret leakage, idempotency, and supply-chain risk.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Plan Noise Reduction & Refresh Strategy Prompt
Kill perpetual-diff noise in Terraform plans — refresh strategy, ignore_changes, provider default drift, and -refresh=false trade-offs.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Intermediate
Terraform Azure Naming Convention Module Prompt
Design a Terraform naming/abbreviation module for Azure that produces compliant, length-limited, globally-unique resource names with deterministic outputs.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform CIDR & Subnet Calculation Design Prompt
Get cidrsubnet/cidrsubnets/cidrhost math right so subnet layouts are non-overlapping, correctly sized, and stable as the network grows.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform EKS Cluster Module Review Prompt
Review a Terraform-managed EKS cluster and node groups for upgrade safety, IRSA/access wiring, and changes that silently replace the control plane or nodes.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Forced-Replacement Cause Triage Prompt
Pinpoint exactly which argument forced a `-/+` replacement in a terraform plan, and whether it can be avoided with ignore_changes, a moved block, or a different value.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform GCP Project Factory Design Prompt
Design a Terraform project-factory pattern that provisions GCP projects consistently — folder placement, billing, APIs, IAM, and quotas — with for_each over a project map.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform helm_release Resource Review Prompt
Review helm_release resources managed in Terraform for value drift, noisy diffs, upgrade safety, and the provider-bootstrap ordering trap.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform IAM Policy Document Refactor Prompt
Refactor inline JSON IAM policies into composable aws_iam_policy_document data sources with least privilege, while keeping the rendered policy semantically identical.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform RDS Zero-Downtime Change Plan Prompt
Analyze an RDS/Aurora terraform plan to tell in-place modifications from replacements, and sequence changes so the database isn't recreated or taken offline.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform time_rotating Resource Design Prompt
Design safe rotation cadence with the time provider (time_rotating, time_offset) so credentials, certs, and tokens regenerate on schedule without thrashing every plan.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform VPC Network Module Design Prompt
Design a reusable, greenfield VPC/network module with clean variable inputs, computed subnet layout, and stable outputs other stacks can consume.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Check Block Scoped Data Source Prompt
Design `check` blocks that use scoped data sources to assert post-apply runtime health (endpoints, DNS, cert expiry) as non-blocking warnings instead of hard plan failures.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform for_each Set vs Map Keys Prompt
Decide whether a `for_each` should iterate a set of strings or a map of objects so instance keys stay stable, readable, and free of churn when the collection changes.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Advanced
Terraform Aliased Provider Passing to Nested Modules Prompt
Wire aliased providers (multi-region, multi-account) down through nested module trees using explicit `configuration_aliases` and `providers = {}` maps instead of implicit inheritance.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Removed Block Forget-Only Prompt
Use a `removed` block with `lifecycle { destroy = false }` to drop a resource from Terraform management without destroying the real infrastructure — the declarative replacement for `terraform state rm`.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Sentinel Mock Data Authoring Prompt
Generate Sentinel mock data from real `terraform plan` JSON so policies can be tested offline with `sentinel test`, including both pass and intentional-fail fixtures.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
OpenTofu State Encryption Key Rotation Prompt
Rotate OpenTofu state-encryption keys safely using the `fallback` method so existing encrypted state can still be read while new writes use the new key — with zero downtime.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Native Test Run Block Ordering Prompt
Sequence `run` blocks in a `.tftest.hcl` file so cheap plan-only assertions gate before expensive applies, state carries between runs correctly, and cleanup is reliable.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Intermediate
Terraform Workspace State Isolation Audit Prompt
Audit a CLI-workspace setup for accidental cross-workspace coupling — shared resource names, hardcoded values, and missing `terraform.workspace` guards that let one workspace clobber another.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Write-Only Argument Migration Prompt
Migrate existing secret arguments that linger in state (passwords, tokens) to write-only arguments and their `_wo_version` triggers, so sensitive values stop being persisted in the state file.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform CLI Configuration (.terraformrc) Hardening Prompt
Audit and design a hardened CLI configuration file for provider mirrors, plugin cache, and credential helpers across dev and CI
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
terraform_data Replacement for null_resource Prompt
Migrate legacy null_resource + triggers patterns to the built-in terraform_data resource without forcing spurious replacements
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Dynamic Multi-Instance Provider Configuration with for_each Prompt
Use for_each on provider configurations (Terraform 1.9+) to fan resources out across many accounts or regions without hand-written aliases
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Ephemeral Resource Design for Short-Lived Credentials Prompt
Design ephemeral resources and ephemeral values to fetch and pass short-lived secrets without ever writing them to state or plan
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Plan JSON Dependency Graph Export Analysis Prompt
Export and analyze the resource dependency graph from terraform graph and plan JSON to explain ordering and blast radius
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Partial Backend Configuration Patterns Prompt
Design partial backend configuration so the same root module initializes against different state backends per environment without hardcoding secrets
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Resource Precondition and Postcondition Design Prompt
Add lifecycle precondition and postcondition blocks that fail a plan or apply early with clear messages instead of producing broken infrastructure
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Stacks Deferred Changes Planning Prompt
Plan and reason about deferred changes across Stack components so unknown-count expansions apply safely in dependency order
- Claude
- ChatGPT
Open prompt - Terraform Beginner
Variable Definition Precedence Audit Prompt
Trace why a Terraform input variable resolves to an unexpected value by auditing the full tfvars and environment-variable precedence chain
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Conftest Plan-JSON Gating Prompt
Wire conftest (OPA/Rego) into CI to evaluate the `terraform show -json` plan output, so policy violations fail the pipeline on the actual planned changes rather than on static config — with clear pass/warn/deny tiers and readable failure messages.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Cross-State Resource Migration Prompt
Plan and execute moving resources between two separate Terraform state files — splitting a monolith state or consolidating stacks — using `terraform state mv -state-out` (or `removed`+`import`) safely, with locking, backups, and a verified zero-diff outcome.
- Claude
- ChatGPT
Open prompt - Terraform Beginner
Terraform Deprecation Warnings Triage Prompt
Systematically triage and resolve deprecation warnings from `terraform plan`/`init` — deprecated provider arguments, attributes, and interpolation patterns — turning a noisy warning stream into a prioritized, low-risk remediation plan before the next major upgrade breaks the build.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Mock Data Test Fixtures Prompt
Build reusable mock fixtures for the native test framework's `mock_provider`/`override_data` so module tests run fast and offline — exercising logic, validation, and outputs without hitting real cloud APIs or creating billable resources.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Multi-Region Fan-Out Design Prompt
Design a maintainable pattern for deploying the same stack across many regions using provider aliases and module fan-out — avoiding the dead-end where provider configurations cannot be created from `for_each` and copy-pasted per-region blocks proliferate.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Policy Bundle Rollout Strategy Prompt
Plan the staged, versioned rollout of a policy-as-code bundle (Sentinel/OPA/conftest) across many Terraform workspaces and teams — moving rules from advisory to soft-mandatory to hard-mandatory without blocking delivery or causing mass plan failures.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Provider-Defined Functions Authoring Prompt
Design, implement, and document provider-defined functions (Terraform 1.8+) in a Go provider so configs can call typed, side-effect-free helpers instead of brittle string-munging in HCL.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Removed Block Deletion Planning Prompt
Use the declarative `removed` block (Terraform 1.7+) to drop resources or modules from configuration without destroying the underlying infrastructure — or to plan an intentional, reviewable destroy — instead of risky `state rm` surgery.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Stack Component Decomposition Prompt
Decompose a sprawling Terraform stack into well-bounded components along state, blast-radius, and change-frequency seams — deciding what belongs in one state file versus separate stacks wired by remote-state outputs, without creating dependency tangles.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Conditional Resource Pattern Review Prompt
Review and fix conditional resource creation (count toggles, ternaries, optional features) for safety and idempotency.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Cross-Account Resource Migration Prompt
Plan moving Terraform-managed resources between cloud accounts or subscriptions without destroy/recreate or data loss.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Dependency Cycle Resolution Prompt
Diagnose and break Terraform 'Cycle' errors in the resource dependency graph without destroying working resources.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform ignore_changes Lifecycle Audit Prompt
Audit and right-size lifecycle ignore_changes rules that are silently hiding real drift in Terraform plans.
- Claude
- ChatGPT
Open prompt - Terraform Beginner
Terraform Module Version Pinning Audit Prompt
Audit module source version constraints across a Terraform estate to eliminate unpinned, drifting, and risky references.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Nested Module Flattening Prompt
Refactor deeply nested Terraform module hierarchies into a flatter, maintainable composition without recreating resources.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform OIDC CI Authentication Design Prompt
Replace long-lived cloud credentials in Terraform CI pipelines with short-lived OIDC-federated identity.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform State Bloat Reduction Prompt
Diagnose and reduce oversized Terraform state causing slow plans, lock contention, and wide blast radius.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform State Pull/Push Manual Edit Safety Prompt
Plan a safe manual state edit via pull/push when CLI state commands cannot fix a corrupted or mis-tracked entry.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
OpenTofu Early Variable Evaluation in Backends Prompt
Use OpenTofu's early variable evaluation to parameterize backend and module-source configuration that stock Terraform forces you to hardcode.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform for_each Key Stability Audit Prompt
Diagnose why a for_each resource is destroying and recreating instances on every plan because its map keys are unstable or derived from computed values.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Module Passed Provider Configuration Prompt
Correctly pass aliased provider configurations into a child module via configuration_aliases so multi-region or multi-account modules work without hidden provider inheritance.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Monolith to Modules Refactor Prompt
Break a sprawling single root module into reusable child modules using moved blocks so addresses stay intact and no resource is destroyed.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Plan Cost Gate in CI Prompt
Add an automated cost-delta gate to a Terraform pipeline that blocks or flags pull requests whose plan increases monthly spend beyond a threshold.
- Claude
- Copilot
Open prompt - Terraform Advanced
Terraform Remote State Data Source Boundaries Prompt
Design clean consumption of one stack's outputs by another using terraform_remote_state, deciding what to expose versus reading provider data sources directly.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Targeted Replace Workflow Prompt
Decide when and how to force-recreate a single resource safely using terraform plan -replace instead of the deprecated taint command, with a back-out plan.
- Claude
- Cursor
Open prompt - Terraform Advanced
Terraform Test Provider Mocking Prompt
Write fast, offline terraform test suites that use mock_provider and overrides so module logic is validated without provisioning real cloud resources.
- Claude
- ChatGPT
Open prompt - Terraform Beginner
Terraform Variable Type Constraints Design Prompt
Design precise complex type constraints for module inputs using object, map, and optional() so misuse fails fast at plan time with clear errors.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform CI Concurrency and Run Queueing Prompt
Prevent concurrent Terraform runs from colliding on the same state by designing locking, queueing, and serialization across CI pipelines.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Known After Apply Debugging Prompt
Untangle plans where too many values show `(known after apply)`, causing unnecessary churn, cascading replacements, or unreviewable diffs.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Lock File Cross-Platform Hashes Prompt
Diagnose and fix `.terraform.lock.hcl` failures caused by missing per-platform provider hashes when developers and CI run on different OS/architectures.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Module Deprecation Path Prompt
Plan a non-breaking migration when a published Terraform module's interface or behavior must change, so existing consumers can upgrade gradually.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Optional Object Attributes Prompt
Design backward-compatible module interfaces using `optional()` object attributes with defaults instead of a sprawl of flat variables.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Output Consumption Pipeline Prompt
Safely consume `terraform output -json` in downstream scripts, pipelines, and other tools without leaking secrets or coupling to fragile parsing.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Saved Plan Artifact Security Prompt
Harden the handling of saved `tfplan` files in CI so plan artifacts do not leak secrets or get applied with stale or tampered contents.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Plan JSON to PR Comment Prompt
Turn raw `terraform show -json` plan output into a compact, scannable pull-request comment that a reviewer can approve or reject in under a minute.
- Claude
- ChatGPT
Open prompt - Terraform Beginner
Terraform Provider Plugin Cache Prompt
Speed up `terraform init` in CI and local dev by configuring a shared provider plugin cache without breaking lock-file integrity.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Atlantis Server Setup & Workflow Prompt
Stand up a self-hosted Atlantis server for pull-request Terraform automation — repo allowlist, server-side workflows, autoplan, apply locks, and policy checks — with sane security defaults.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Core Version Upgrade Prompt
Plan a safe upgrade of the Terraform CLI/core version across many stacks — required_version constraints, deprecation handling, state compatibility, and a staged rollout that won't strand teams.
- Claude
- ChatGPT
Open prompt - Terraform Beginner
Terraform Module Documentation Generation Prompt
Auto-generate clear, consistent module documentation with terraform-docs — inputs, outputs, requirements, usage examples — and enforce it in CI so READMEs never drift from the code.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Error Message Debugging Prompt
Diagnose cryptic Terraform plan/apply errors — provider API faults, cycle errors, type mismatches, unknown-value-at-plan-time, and inconsistent-final-plan — and get a concrete fix path.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform GitHub Actions Pipeline Prompt
Design a production-grade GitHub Actions workflow for Terraform that runs fmt/validate/plan on PRs, posts plan summaries as comments, and gates apply behind environments and OIDC cloud auth.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Self-Service Module Platform Prompt
Design a golden-path self-service platform where app teams provision infrastructure through curated, opinionated Terraform modules with guardrails, scaffolding, and a private registry — minimizing copy-paste and blast radius.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Sensitive Output Audit Prompt
Audit a Terraform codebase for leaked secrets — sensitive values landing in outputs, logs, state, or CI artifacts — and apply sensitive flags, ephemeral handling, and redaction to stop exposure.
- Claude
- ChatGPT
Open prompt - Terraform Beginner
Terraform Resource Tagging Strategy Prompt
Design and enforce a consistent resource tagging strategy in Terraform — default_tags, merged module tags, mandatory keys for cost allocation and ownership — without per-resource boilerplate.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Apply Performance Tuning Prompt
Diagnose and speed up slow `terraform plan`/`apply` runs on large states — provider rate limits, refresh cost, parallelism, targeted operations, and state splitting — without compromising safety.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Check Blocks & Post-Apply Assertions Prompt
Add `check` blocks with scoped data sources and assertions that validate live infrastructure after apply — endpoints reachable, TLS valid, DNS resolving — turning silent misconfigurations into loud plan/apply warnings.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform CI Log Secret Redaction Prompt
Stop secrets from leaking into CI logs and PR plan comments — audit where Terraform exposes sensitive values, enforce `sensitive`, mask provider output, and scrub `terraform show -json` before posting.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Module SemVer & Release Strategy Prompt
Define a semantic-versioning and release process for an internal Terraform module library — what counts as breaking, how to tag, deprecate inputs, and let consumers pin safely across a fleet of root modules.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Provider Development Scaffolding Prompt
Scaffold a custom Terraform provider with the Plugin Framework — resources, data sources, schema, CRUD, import, and acceptance tests — for wrapping an internal API that has no existing provider.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Resource Targeting Strategy Prompt
Use `-target`, `-replace`, and `-exclude` deliberately and safely — for surgical fixes, breaking dependency deadlocks, and forcing replacement — while understanding the partial-state risks each one introduces.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Stacks Deployments Design Prompt
Design a Terraform Stacks (HCP) configuration that splits components from deployments, so one set of modules fans out across regions, accounts, and environments with orchestrated dependency ordering.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform State Disaster Recovery & Rebuild Prompt
Recover from a lost, corrupted, or diverged Terraform state file — rebuild state via bulk import, reconcile against live infrastructure, and harden the backend so it never happens again.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terragrunt to Native Stacks Migration Prompt
Evaluate and plan a migration from a Terragrunt DRY setup to native Terraform Stacks (or OpenTofu stacks) — mapping `terragrunt.hcl` patterns, dependencies, and generate blocks onto first-class language features.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform count-to-for_each Migration Prompt
Safely migrate index-based `count` resources to keyed `for_each` so inserting or removing one item stops recreating every resource after it — using `moved` blocks and state moves, with a zero-change plan as proof.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Ephemeral & Write-Only Secrets Prompt
Use Terraform 1.10+ ephemeral resources, ephemeral values, and write-only arguments to flow secrets through configuration without ever persisting them in state or plan files.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Import Block Generation Prompt
Bring existing, hand-created cloud resources under Terraform using config-driven `import` blocks and `-generate-config-out` — then refine the generated HCL until the plan is a clean no-op.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Monorepo Structure Prompt
Design an org-scale Terraform monorepo — root modules, shared modules, environment boundaries, ownership via CODEOWNERS, and path-scoped CI — so hundreds of stacks stay navigable and changes have a tight blast radius.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Native Test Framework Prompt
Write `.tftest.hcl` tests using Terraform's built-in test framework — `run` blocks, `command = plan` vs `apply`, assertions, mocks, and providers — to validate modules in CI without third-party tooling.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Plan Output Summarization Prompt
Turn a noisy 4,000-line `terraform plan` into a crisp, reviewer-friendly summary — grouped by action, risk-ranked, with the dangerous changes surfaced first — for PR comments and approvals.
- Claude
- ChatGPT
Open prompt - Terraform Beginner
Terraform Provider Mirror for Air-Gapped CI Prompt
Set up a Terraform provider mirror (filesystem or network mirror) and `.terraformrc` so `terraform init` works in air-gapped or rate-limited CI without reaching the public registry.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Spacelift Stack & Policy Design Prompt
Design Spacelift stacks, spaces, contexts, and Rego policies for a Terraform org — trigger graphs, drift detection, approval gates, and least-privilege access — instead of bolting GitOps onto raw CI.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terragrunt DRY Configuration Prompt
Restructure a sprawling multi-account, multi-region Terraform repo into a DRY Terragrunt layout — root config, includes, dependency wiring, and run-all orchestration — without breaking existing state.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Brownfield Adoption Prompt
Bring existing, hand-built cloud infrastructure under Terraform management safely — discovery, prioritized import waves, codegen, reconciling drift, and proving the first plan is a clean no-op.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Change Blast Radius Analysis Prompt
Before approving a Terraform PR, quantify the blast radius — which resources replace vs update in place, hidden cascade effects, downtime windows, and cross-module ripple — so reviewers approve with eyes open.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Dependency Lock File Management Prompt
Tame the `.terraform.lock.hcl` file — multi-platform hashes, controlled provider bumps, CI verification with `-lockfile=readonly`, and resolving the merge conflicts and 'checksum not in lock' errors that follow.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Drift Remediation Runbook Prompt
Turn detected drift into a safe, decision-driven remediation runbook — classify each drift, decide code-wins vs reality-wins, handle out-of-band changes, and codify guardrails so the same drift doesn't recur.
- Claude
- ChatGPT
Open prompt - Terraform Beginner
Terraform Locals & Expression Readability Prompt
Refactor gnarly Terraform expressions into clear, testable locals — taming nested for/conditionals, flatten/setproduct patterns, type coercion, and the unreadable one-liners that hide bugs.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Module Output Contracts Prompt
Design stable, well-typed module outputs that downstream modules can depend on — output naming, sensitive marking, object vs flat outputs, and versioning the contract so consumers don't break on every refactor.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Module Registry Publishing Prompt
Publish a reusable module to a public or private registry the right way — repo naming and structure, semantic version tags, examples and docs, automated release, and a consumer-friendly versioning policy.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Provisioners & local-exec Escape Hatch Prompt
Decide when (rarely) to use Terraform provisioners and how to do it safely — local-exec vs remote-exec vs null_resource, idempotency, failure handling, and the native alternatives that almost always beat them.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform State Encryption at Rest Prompt
Design end-to-end encryption for Terraform state — backend-side KMS, OpenTofu native state encryption, secrets that leak into state, and a key-rotation plan that won't lock you out.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Remote Backend Migration Prompt
Move Terraform state from one backend to another (local → S3, S3 → Terraform Cloud, or cross-account/region) with locking intact, zero state loss, and a tested rollback at every step.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Cost Estimation with Infracost Prompt
Wire per-PR cost estimation into Terraform reviews — surface the monthly delta of every plan, set budget guardrails, and turn cost into a first-class part of code review instead of a surprise on the bill.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Data Sources Design Prompt
Decide when to wire infrastructure together with data sources vs remote-state outputs vs hardcoded values — avoiding hidden coupling, plan-time failures, and the dreaded 'data source depends on a resource not yet created' trap.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Dependency Graph Debugging Prompt
Diagnose cycle errors, unexpected resource ordering, and 'value not known until apply' problems by reading Terraform's dependency graph and reshaping references instead of guessing with `depends_on`.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Destroy Safety Prompt
Tear down infrastructure deliberately — guarding stateful resources, ordering deletes correctly, draining dependencies, and proving exactly what will be destroyed before anything irreversible happens.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Moved & Import Blocks Prompt
Use declarative `moved` and `import` blocks to refactor and adopt resources without manual `terraform state mv`/`import` — keeping every change reviewable in a plan and reproducible in CI.
- Claude
- ChatGPT
Open prompt - Terraform Beginner
Terraform Pre-Commit & Linting Toolchain Prompt
Stand up a layered Terraform quality gate — fmt, validate, tflint, tfsec/checkov, terraform-docs, and trivy — wired through pre-commit so the same checks run on laptops and in CI without bikeshedding.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Provider Version Upgrade Prompt
Plan and execute a safe major-version provider upgrade (e.g. AWS 4.x → 5.x) by reading the changelog, mapping breaking changes to your code, and staging the rollout so no plan ever silently destroys resources.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Workspace-Per-Tenant Design Prompt
Design a scalable workspace strategy for multi-tenant or many-account fleets — deciding between CLI workspaces, separate state files, and TFC/TFE workspaces so you can manage hundreds of near-identical stacks without copy-paste sprawl.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform AWS Provider Patterns Prompt
Common Terraform AWS patterns — VPC + subnets, EKS, RDS, ALB, S3, IAM roles, naming conventions.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Secrets & Sensitive Variables Prompt
Manage secrets in Terraform — sensitive flag, ephemeral resources, external secret managers, plan/state masking.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Variable Validation Prompt
Add Terraform variable validation — types, validation blocks, sensitive, nullable, custom error messages.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Dynamic Blocks Prompt
Generate nested blocks dynamically — security group rules, tags, conditional blocks, complex iteration.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform `for_each` vs `count` Prompt
Choose between for_each and count for resource iteration — key stability, addition/removal behavior, when to use each.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Drift Detection Prompt
Detect Terraform drift — scheduled plans, refresh, drift reporting, alerting, distinguishing manual changes from external mutations.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Policy-as-Code (Sentinel / OPA / Checkov) Prompt
Implement policy-as-code for Terraform — Sentinel (TFC), OPA/Conftest, Checkov, tfsec, enforce security and compliance.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform → OpenTofu Migration Prompt
Migrate from Terraform to OpenTofu — state compatibility, provider replacement, CI updates, feature differences.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform CI/CD: Atlantis, Cloud, GitOps Prompt
Choose and configure Terraform CI/CD — Atlantis, Terraform Cloud, Spacelift, custom CI; plan/apply workflows, approvals.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Large State Refactor Prompt
Refactor large Terraform state — moved/removed blocks, splitting state files, extracting modules without destroy.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Plan Review Checklist Prompt
Review Terraform plan output — read 'destroy', 'replace', 'create', identify dangerous changes, automate review.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Cloud Provider Authentication Best Practices Prompt
Authenticate Terraform to cloud providers safely — AWS IAM roles, GCP service accounts, Azure managed identity, OIDC from CI.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
CloudFormation to Terraform Conversion Prompt
Convert an AWS CloudFormation template (YAML or JSON) into idiomatic Terraform HCL — preserving behavior, improving readability.
- Claude
- ChatGPT
- Cursor
Open prompt - Terraform Intermediate
Terraform Provider Configuration & Aliases Prompt
Configure Terraform providers — version constraints, aliases for multi-region/multi-account, required_providers.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform Module Testing Prompt
Test Terraform modules — terraform test (1.6+), terratest (Go), unit vs integration, mocking providers.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Module Composition Prompt
Design Terraform modules — input/output contracts, composition, versioning, public vs private registry, when to abstract.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Multi-Environment Design Prompt
Design Terraform for multiple environments — dev/staging/prod separation, tfvars patterns, account boundaries, promotion workflow.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform Workspaces vs Directory Structure Prompt
Choose between Terraform workspaces and directory-per-env — when each is appropriate, migration patterns.
- Claude
- ChatGPT
Open prompt - Terraform Intermediate
Terraform State Locking Debug Prompt
Diagnose Terraform state lock issues — DynamoDB / GCS / Azure lease locks, stuck locks, force-unlock, multi-runner contention.
- Claude
- ChatGPT
Open prompt - Terraform Advanced
Terraform State Surgery & Import Prompt
Perform Terraform state operations — terraform state mv/rm/import, replace, large-scale imports via import block.
- Claude
- ChatGPT
Open prompt
About these Terraform AI prompts
This is a free, curated collection of Terraform AI prompts for DevOps and platform engineers — prompt templates that turn Claude, ChatGPT, or Cursor into a focused Terraform 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 Terraform.
Browse all 146 above, or explore the wider Terraform 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.