A terraform plan scrolls past in CI, someone types yes, and twenty minutes later the load balancer is gone. The plan said -/+ on three resources — force-new — but nobody read it. That is the gap these prompts close: not by replacing your judgment, but by making the LLM read the plan line by line and explain what will actually happen before you type yes. Below are the prompts I reach for when reviewing Infrastructure as Code, each with a real example of what comes back — and where the model still gets it wrong.
The prompt that turns a plan into a sentence you can argue with
Most teams already pipe terraform plan into a file. The trick is to give the LLM the plan output and the variable values, not the whole repo. Ask for a resource-by-resource verdict: what changes, why, and whether it is reversible.
Prompt:
You are reviewing a Terraform plan before apply. Below is the plan output and the variable values. For each resource with an action other than no-op, output a table with columns: address, action (create/update/replace/delete), what changes, is it destructive (data loss or downtime), and can it be rolled back by re-applying the previous config. Then list any resource where the action is replace or delete and explain in one sentence why Terraform chose it. Do not guess provider behavior; if the plan does not show enough, say so.
Example output for a plan that replaces an aws_db_instance because engine_version changed:
| address | action | what changes | destructive | rollback |
|---|---|---|---|---|
| aws_db_instance.main | replace | engine_version 14.9 → 15.4 | yes, new instance, old deleted | no, data not migrated |
| aws_security_group.web | update | ingress rule added | no | yes |
The value is not the table — it is the sentence “why Terraform chose it.” Here the model points at engine_version being force-new. That is the moment you stop and check whether a blue/green migration is planned. Without the prompt, that line is buried on page 4.
Drift is not a plan failure — it is a state lie
Drift shows up when terraform plan says “no changes” but the real infrastructure has moved. The LLM cannot call your cloud API, so the prompt has to work from terraform state show and a fresh terraform refresh diff. Ask it to compare the two and name which attribute drifted.
Prompt:
Here are two outputs: (1) terraform state show for aws_instance.web, (2) the same resource as returned by a refresh (terraform plan -refresh-only). List every attribute that differs, mark which ones are managed by Terraform vs set by the cloud provider, and say whether the drift is safe to ignore or must be reconciled. If an attribute is not in the state, say “not tracked.”
A typical answer flags tags added manually in the console and user_data changed outside Terraform. The model will often suggest terraform apply -refresh-only — correct in principle, but it does not know your team's policy on manual changes. That is your call.
If you want a deeper walkthrough of how drift and destructive changes are caught in practice, the team at asibiont has a full breakdown: Your YAML Isn't Too Specific for an LLM: How to Prompt Kubernetes and Terraform Reviews That Catch Crashes Before Prod.
Force-new and missing prevent_destroy: the two patterns that cost the most
A replace on a database is expensive. A delete on a bucket without prevent_destroy is permanent. The prompt here is a checklist, not a conversation.
Prompt:
Scan this Terraform configuration for resources that (a) have lifecycle.prevent_destroy = false or missing on stateful resources (databases, buckets, volumes), (b) any attribute in the resource that is known to force replacement (mark with “force-new risk”), and (c) any module call where a variable change would cascade to a replace. Output a list with file:line and a one-line fix. Do not invent attribute names; if unsure, say “verify in provider docs.”
Example output:
modules/storage/main.tf:12—aws_s3_bucket.datahas noprevent_destroy. Fix: addlifecycle { prevent_destroy = true }.modules/db/main.tf:34—engine_versionchange forces replace. Fix: pin version or usecreate_before_destroywith a migration plan.
Notice the model does not claim to know every force-new attribute. That caveat is the honest part — and the reason you still open the provider docs for the exact resource.
Ansible: idempotent by prompt, not by hope
Ansible playbooks fail idempotency in predictable ways: shell instead of command, state: latest on packages, and copy without checksum. Ask the LLM to rewrite a playbook with idempotency rules stated explicitly.
Prompt:
Rewrite this Ansible playbook to be idempotent. Rules: no shell/command unless no module exists (then add changed_when and creates), no state: latest, use template with checksum, and every task must have a name. Output the full playbook and a list of changes with the reason for each.
Example change: a shell: apt-get install nginx becomes ansible.builtin.apt: name=nginx state=present. The model will also add changed_when: false to read-only commands. That is the kind of detail that saves a debugging session at 2 a.m.
For more on turning Ansible and Terraform reviews into a repeatable LLM workflow, see Terraform Prompts That Think Like an SRE: Turning an LLM Into a Module Author, Plan Reader, and Drift Hunter.
Cyclic dependencies: the module graph the LLM can see
Terraform does not allow cycles. But module-level cycles — where module A outputs feed module B and B outputs feed A — show up as “cycle” errors only at plan time. Ask the LLM to read the module blocks and output references and draw the graph.
Prompt:
Here are the module blocks and outputs from my Terraform config. Build a dependency graph where an edge exists if module X uses an output from module Y. List any cycle (A → B → A). For each cycle, suggest a break point: move the shared resource to a separate module or pass the value as a variable. Do not suggest changing provider behavior.
A common answer: “module.network outputs vpc_id to module.app, and module.app outputs subnet_ids back to module.network — break by moving subnet creation into module.network.” That is a design fix, not a syntax fix — which is exactly what you want from a reviewer.
- Explaining every resource change in a plan
- Spotting force-new / delete patterns
- Drafting idempotent Ansible tasks
- Finding cyclic module dependencies
- Provider version-specific arguments
- HCL syntax quirks and interpolation
- Actual cloud API behavior
- State file integrity and locking
The version trap: why you still check HCL by hand
LLMs are trained on a mix of Terraform provider versions. A prompt that asks “is this attribute force-new?” may return an answer correct for AWS provider 4.x but wrong for 5.x. The same goes for Ansible module arguments — ansible.builtin.apt gained and lost options across versions.
A practical rule: after the LLM flags a force-new attribute, run terraform providers schema -json and grep for the attribute. If it is not there, the model hallucinated. For Ansible, check ansible-doc <module> before trusting a suggested argument. This two-minute check is the difference between a helpful review and a broken pipeline.
If you are still deciding whether Infrastructure as Code is worth the overhead, the myths article is a good reality check: Terraform & IaC: The Myths That Cost You Money and How Infrastructure as Code Actually Works.
A short workflow that fits in a CI step
terraform plan -out=tfplanandterraform show -json tfplan > plan.json.- Pipe
plan.jsonandterraform.tfvarsinto the LLM prompt from section one. - If the model flags any
replaceordeleteon a stateful resource, fail the CI step and require a human override. - For Ansible, run the idempotency prompt on changed playbooks and diff the output against the original.
- Keep a
prevent_destroycheck as a separate prompt — it is fast and catches the most expensive mistake.
That is the whole loop: plan → explain → flag → human decides. The LLM does not type yes for you. It just makes sure you know what you are saying yes to.
If you want to see how the same approach works for backend leaks and crash triggers, the prompts in Your Backend Is a Slow Leak: LLM Prompts That Catch Memory Hogs, Query Bloat, and Crash Triggers Before the Pager Goes Off follow the same “read the output, not the code” logic.
The next time a plan scrolls past, do not scroll with it. Paste it into the prompt, read the table, and ask the model why. That habit alone will catch the force-new you would have missed.
Rules and figures are stated as of November 2026.