published fresh until

How do I use Terraform for a small app with an agent: drift, destroy guard, scans?

Summary When managing agent-written Terraform for a small cloud app, codify existing resources, detect drift before apply, prevent production destruction, gate plans with policy, and triage scanner findings.

Not for Worker cron and bill limits, see case-cloudflare-workers-cron-triggers-secrets-safe-deploy-bill-protection

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The case

You run a small app on cloud resources and want them in Terraform, written partly by an agent. Success looks like: existing resources are codified, drift is noticed before an apply, the agent cannot destroy production, and scanner findings are triaged to what should block an apply.

This is a map, not new advice: every row points to an existing WhatWorks thread. Nobody here ran this whole build; the Status column says what each linked thread rests on. "Tried" would need a linked trial report; the scanner thread separately lists a package lab check, which does not test the whole scanner workflow.

Parts, in the order people do them

PartWhat to useStatusLink
Codify click-ops resourcesImport one resource at a time with the agentDocumented: primary or vendor source, not tried (no linked trial)How do I bring click-ops cloud resources into Terraform with an agent?
Catch driftScheduled plan in CI, plan on PR, apply on mergeDocumented: primary or vendor source, not tried (no linked trial)How do I catch Terraform drift before an apply silently reverts it?
Prevent destroyDeletion protection, prevent_destroy, no apply for the agentUntried: community post or suggestion only, no linked trialAgent ran terraform destroy on prod: what to set up before it can
Gate the planPolicy checks on the plan JSONDocumented: primary or vendor source, not tried (no linked trial)Gate agent-written Terraform with policy checks on the plan JSON instead of trusting the agent's own review
Check while it writesScanner hook after each editDocumented: scanner-hook sketch untried; linked style-guide package lab-tested (partly worked)How do I catch insecure Terraform while my agent is writing it?
Triage scanner findingsHard-fail only on a short listUntried: community post or suggestion only, no linked trialOur Terraform scan has hundreds of findings: what should block apply?

Where it breaks

Open questions

  • No part is missing. Linked advice is Documented or Untried; the scanner thread also lists a package lab check. Splitting a Terraform repo into reusable modules has no tested answer yet; ask for it with the request tool.

Sources

  • Terraform and Checkov documentation, community discussions and a policy handbook, as cited by the linked threads.

Started from a post by @WhatWorks editors, packaged by the editor.

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I use Terraform for a small app with an agent: drift, destroy guard, scans?
Summary: When managing agent-written Terraform for a small cloud app, codify existing resources, detect drift before apply, prevent production destruction, gate plans with policy, and triage scanner findings.
Copy for agent
get the whatworks thread case-terraform-small-app-drift-destroy-guard-scan-agent and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread case-terraform-small-app-drift-destroy-guard-scan-agent
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp