AI Code Reviewer: Serverless PR Reviews with Bedrock
Every GitHub pull request and GitLab merge request gets an AI review flagging security holes, quality issues, and performance problems within seconds - served by a fully serverless AWS pipeline that costs pennies per review.

- Git platforms supported
- 2
- Git platforms supported
- Endpoint protection layers
- 4
- Endpoint protection layers
- Merge/close on review severity
- Auto
- Merge/close on review severity
The Challenge: Code Review Is the Bottleneck
Security reviews are the first thing teams skip when the queue is long. Hardcoded secrets, SQL injection, unbounded loops - they slip through because no human had time to read the diff before merge. The fix is not “review harder”; it is giving every pull request an instant first-pass reviewer that never gets busy.
This project is a fully serverless AI code reviewer that comments on every GitHub pull request and GitLab merge request within seconds - flagging security holes, code-quality issues, and performance problems - and can auto-merge or auto-close changes based on what it finds. It runs on a handful of AWS managed services and costs pennies per review.
How It Works
A single webhook URL connects any repository. The request path is built entirely on managed services with no servers to operate:
1 · Webhook in
GitHub or GitLab pushes the PR/MR event to API Gateway - rate-limited at 10 req/s (burst 20) and behind a per-IP WAF rate rule.
2 · Verify
An ingest Lambda confirms the payload is genuinely from the Git provider with an HMAC signature check against a secret stored in AWS Secrets Manager; forged requests get 401.
3 · Queue
Verified events land in SQS, decoupling bursty webhook traffic from slow LLM calls and giving free retries on transient failures.
4 · Review
A worker Lambda fetches the diff from the Git API, sends it to Amazon Bedrock (Nova), and posts a structured review comment on the PR - findings, severity, and fixes.
5 · Act
Based on finding severity the worker can merge clean changes automatically or close PRs carrying high-severity issues, according to policy flags.

Defense in Depth on a Public Endpoint
A webhook that triggers LLM spend must not be open to the internet. Every layer earns its place:
Cognito Authorizer
A Lambda authorizer requires a valid bearer token for API callers - only recognized Git webhooks are exempt
HMAC Signatures
Payloads are verified against shared secrets per provider; forged GitHub or GitLab events are rejected with 401
Throttling + WAF
Stage-level throttle (10 req/s, burst 20) returns 429 under load; a WAF rate rule blocks per-IP floods
Budget Alarm
A billing alarm emails the moment monthly spend crosses the limit - the last line against runaway LLM cost
Policy-Driven Auto-Merge & Auto-Close
The reviewer does not just advise - it enforces. Review severity maps to merge policy through environment flags on the worker, so teams choose how much autonomy to grant:
| Review outcome | Action | Policy flag |
|---|---|---|
| No high-severity issues | Auto-merge | MERGE_ON_LOW_SEVERITY (default on) |
| Medium findings only | Auto-merge (opt-in) | MERGE_ON_MEDIUM_SEVERITY |
| High-severity findings | Auto-close PR/MR | CLOSE_ON_HIGH_SEVERITY (default on) |


The same policies run on GitLab merge requests - high-severity changes are closed, clean reviews are merged, no extra integration code:


Every Review Has a Price Tag
LLM features die from surprise bills, so cost is a first-class output. Each review is recorded in DynamoDB with input/output tokens, processing time, files analyzed, findings count, and actual USD cost - attributed by provider:repo:month and individual PR, so teams can see exactly what AI review costs them per repository and per change.

Operated as Code
The entire stack is one CloudFormation template deployed via deploy.sh, with outputs (endpoint URL, user pool, client IDs) queryable from the stack. Pushing to main triggers lint and deploy through GitHub Actions, and swapping the underlying Bedrock model is a single line in a YAML config - no code changes, no redeploy of application logic. Correctness is guarded by 11 pytest suites covering the ingest path, Lambda authorizer, worker, and both provider integrations, with ruff enforcing style in the same pipeline.
# Deploy the whole reviewer in one command
./deploy/deploy.sh --region us-east-1 \
--github-token 'ghp_...' --webhook-secret 'shared-secret'
# Find the live endpoint
aws cloudformation describe-stacks --stack-name pr-reviewer \
--region us-east-1 \
--query 'Stacks[0].Outputs[].{key:OutputKey,value:OutputValue}' \
--output tableSkills & Technologies
Like what you're seeing?
I'm always up for tackling challenging infrastructure, automation, and AI/DevOps problems. Let's build something together.