
How I Review Terraform and Lambda PRs with AI Before They Merge
How I use AI as a first-pass reviewer for Terraform and Lambda pull requests, while keeping human judgment on the risky parts

How I use AI as a first-pass reviewer for Terraform and Lambda pull requests, while keeping human judgment on the risky parts
If my earlier posts were about how I write infrastructure and how I build AI-assisted workflows, this one is about the gate right before merge.
That distinction matters. Writing code with AI is useful. Reviewing production changes with AI is where the real value shows up for me. The problem is not getting a first draft fast. The problem is making sure the change is still safe when it touches IAM, Terraform state, Lambda runtime settings, or anything that can quietly cost money or break production.
So I started using AI as a first-pass reviewer for Terraform and Lambda pull requests. Not as the decision maker. Not as the person who approves the merge. Just as the reviewer that helps me catch the obvious and semi-obvious issues before I spend my own time on the full manual pass.
That keeps the review fast, but it also keeps the final responsibility where it belongs, with me.
This post is the workflow I trust today.
Short version: AI reviews the diff, I review the risk.
I already write about AI in AWS codebases, Terraform workflows, and agentic DevOps routines. This post is not another version of that same story.
The earlier posts focus on one of two things:
This one is narrower. It is about reviewing a production change before it merges.
That narrower scope makes it more useful in practice, because the questions are more specific:
That is the kind of review AI is actually good at helping with.
I do not ask the model to guess from thin air. I give it the actual change surface.
Typically that means some mix of:
The quality of the review depends on the input. If I give it a sloppy prompt, I get a sloppy review. If I give it the real plan and the real diff, it can usually spot the things I want it to spot.
I want the reviewer to answer a simple question: what would make this change risky to merge?
For Terraform and Lambda work, I care about a small set of risk categories more than anything else.
This is the first thing I look at because permission creep is easy to miss in a diff. A policy can go from narrow to broad with one extra wildcard or one extra resource pattern.
I want AI to flag:
Lambda changes can look tiny and still affect cost or reliability.
I want the reviewer to notice things like:
This is where production changes can become unpleasant. A harmless-looking refactor can trigger a destroy-and-recreate path if someone changes the wrong attribute.
I want the model to call out:
Anything that changes public access, private access, VPC wiring, or routing deserves extra attention.
I want the reviewer to be loud about:
Even if the code is correct, the review is not complete if the PR forgot the operational side.
So I want AI to ask about:
AI helps me move faster, but some things should stay human-led.
My manual pass focuses on:
I also sanity-check anything that looks too confident. If the model says a change is safe, that is not enough. I want the evidence behind the claim.
The best outcome is not “AI approved it.” The best outcome is “AI surfaced the right questions before I reviewed it.”
The flow is pretty simple.
That sounds basic, but it works because it keeps the review structured.
Here is the kind of prompt I use conceptually:
You are reviewing a production AWS change.
Focus on:
- IAM and permissions
- Terraform replacement risk
- Lambda runtime and cost impact
- networking and exposure
- missing rollback or operational detail
Return:
1. plain-English summary of the change
2. top risks ranked by severity
3. specific lines or resources that look suspicious
4. questions I should answer before merge
5. a merge recommendation: safe, caution, or block
I do not need poetry from the reviewer. I need a compact risk report I can act on.
Sometimes the most useful thing the AI does is not catch a mistake outright. It points out that something deserves a question.
Examples:
That kind of review is valuable because it slows me down in the right place. It makes the risky bit visible before I merge.
If I compare this to my other posts, the shape is different.
Earlier posts are about:
This one is about the final gate before the change goes live.
That is why I think it is a good companion piece instead of a duplicate. It belongs in the same family, but it answers a different question.
One post is about the tools that help me work. This post is about the review layer that keeps me honest.
There are a few failure modes I do not want from an AI reviewer.
If the model cannot explain the risk, it is not helping much.
AI review works best when it makes the important things easier to see, not when it replaces judgment.
That is the real pattern I keep coming back to in AWS work. I want speed, but I want it inside a review process that still respects the cost of being wrong.
So yes, I use AI to review Terraform and Lambda PRs. But the point is not to automate approval. The point is to catch the risky stuff earlier, ask better questions, and make the human review sharper.
That is the version I trust in production.
I email when a new post goes up. One send a week, and only if there's something new.
Want this applied on your account? Start with Infrastructure as Code.
Related reading
Kept below the post instead of in a sidebar, with a slow continuous motion for a cleaner editorial feel.
On this post
Comments
A reply stays under the note it answers.
No comments yet.
If you have a note on How I Review Terraform and Lambda PRs with AI Before They Merge, sign in and leave it.