All modules in this track (11)
The old way: an engineer writes a Terraform module, opens a pull request, and a reviewer finds the missing tags, the bucket without encryption, the name that breaks the convention. Back and forth, three rounds. The new way: by the time a human sees the change, the tags are there, the encryption is on, the name follows the convention, the tests pass, and the security scan is clean. The review is about the design, not the basics.
That's what "compliant by design" means. In late 2025, I started delivering platform code this way, with an AI agent doing much of the writing.
From snippets to a workflow
Until now, AI had been a helper I talked to. An agent is different: it can read files, write code, run commands, and check its own results, in a loop, until a task is done.
That's powerful, and risky. An agent that writes code fast can also write non-compliant code fast. So the question changed from "what can the agent write?" to "what must every piece of code pass before anyone accepts it?"
Rules first, then the agent
I built the workflow around the rules, not around the agent:
- The standard comes first. Naming, tagging, module structure, and the security baseline are written down, and the agent reads them before it starts.
- The agent writes the change, following the standard.
- Automatic checks run: format, lint, security scan, tests, and a plan with no surprises. If anything fails, the agent fixes it and runs them again.
- A person reviews it: the design, the risk, and anything the checks can't judge.
- A person approves the deploy. The plan is shown on the pull request, and nothing is applied until someone approves it.
Three things make it work:
- The standard is written down. Naming, tagging, module layout, and security rules live in the repository, where the agent reads them first. The Terraform track describes the kind of standard I mean: base and composition modules, naming and tagging, and module testing.
- The checks are automatic. Linting, security scanning such as Checkov, and
terraform testrun on every change. The agent runs them too, before it says it's done. - A person still decides. Every change goes through review, and nothing is applied to an environment without a person approving it, the same promotion gate any engineer's code goes through.
Review gets better, not just faster
- Fewer review rounds. The basics are already right, so reviews focus on design and risk.
- More consistent code. The agent follows the standard every time. People forget; written rules don't.
- Standards got sharper. When the agent did something odd, the cause was usually a gap or an unclear line in the standard. Fixing the standard fixed it for every future change.
Responsibility
The agent writes much of the code, but I'm responsible for what gets deployed. A clean scan doesn't prove a design is right. A passing test only checks what someone thought to test. That's why the human review and the approval gate stay, however good the agent gets.
Try it in your workflow: make one rule automatic
- Pick one rule reviewers keep repeating, such as "every resource must have an owner tag".
- Write it down in the repository, in one line, where people and agents will read it.
- Add a check that enforces it automatically on every pull request.
- Next time an agent or a person writes code, see whether the rule is followed without anyone asking.
If you're at this stage
- Write the rules before you let the agent write code. An agent amplifies whatever standard it's given, good or missing.
- Automate every rule you can. Checks don't get tired, and they don't skip steps under deadline pressure.
- Keep the human gate. Agents speed up delivery. They don't take over accountability.
Quick check
3 questions. Decide on your answer to each, then check it.
-
Scenario
An AI agent delivers a Terraform module that passes every automatic check. What's still needed before it reaches production?
Show answer
A human review of the design and risk, and an approved plan before apply
Checks prove the code follows the rules they know about. Design choices, blast radius, and fit with the rest of the platform still need a person.
-
Scenario
The agent keeps naming resources slightly differently from your convention. What's the best fix?
Show answer
Write the convention down clearly in the repository and add a check that enforces it
Repeated mistakes usually point to an unwritten or unclear rule. Writing it down and enforcing it fixes it for every future change, from people and agents alike.
-
Concept
What does "compliant by design" mean?
Show answer
Building the rules into how code is written and checked, so compliant code is the default
Compliance by design moves the rules to the start: written standards plus automatic checks, so problems are caught as the code is written, not found at the end.
Next: Chapter 08. February 2026, AGENTS.md, Skills, and MCP.