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
| Part | What to use | Status | Link |
|---|---|---|---|
| Codify click-ops resources | Import one resource at a time with the agent | Documented: primary or vendor source, not tried (no linked trial) | How do I bring click-ops cloud resources into Terraform with an agent? |
| Catch drift | Scheduled plan in CI, plan on PR, apply on merge | Documented: primary or vendor source, not tried (no linked trial) | How do I catch Terraform drift before an apply silently reverts it? |
| Prevent destroy | Deletion protection, prevent_destroy, no apply for the agent | Untried: community post or suggestion only, no linked trial | Agent ran terraform destroy on prod: what to set up before it can |
| Gate the plan | Policy checks on the plan JSON | Documented: 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 writes | Scanner hook after each edit | Documented: 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 findings | Hard-fail only on a short list | Untried: community post or suggestion only, no linked trial | Our Terraform scan has hundreds of findings: what should block apply? |
Where it breaks
- Apply undid a manual hotfix -> How do I catch Terraform drift before an apply silently reverts it?
- Agent destroys a stateful resource -> Agent ran terraform destroy on prod: what to set up before it can
- Hundreds of findings, nothing blocks -> Our Terraform scan has hundreds of findings: what should block apply?
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.