BuildSep 2026

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.

AI Code Reviewer serverless architecture with API Gateway, SQS, Lambda, and Amazon Bedrock Nova reviewing pull and merge requests
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.

AI Code Reviewer architecture: webhook through API Gateway, Lambda authorizer, SQS, and Bedrock Nova worker
Fig 2: Webhook → Cognito/WAF-protected API Gateway → HMAC-verified ingest → SQS → Bedrock Nova worker → PR/MR comment

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 outcomeActionPolicy flag
No high-severity issuesAuto-mergeMERGE_ON_LOW_SEVERITY (default on)
Medium findings onlyAuto-merge (opt-in)MERGE_ON_MEDIUM_SEVERITY
High-severity findingsAuto-close PR/MRCLOSE_ON_HIGH_SEVERITY (default on)
GitHub pull request automatically closed by the AI reviewer after high-severity findings
Fig 3: A GitHub pull request with planted secrets and injection flaws, auto-closed by severity policy
GitHub pull request automatically merged by the AI reviewer after a clean review
Fig 4: A clean GitHub pull request auto-merged once the AI review found no high-severity issues

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

GitLab merge request automatically closed by the AI reviewer after high-severity findings
Fig 5: A GitLab merge request flagged with high-severity findings, auto-closed by the same policy
GitLab merge request automatically merged after a clean AI review
Fig 6: A clean GitLab merge request auto-merged once the AI review found no high-severity issues

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.

AI review comment on a GitHub pull request showing findings and cost metrics
Fig 7: A live AI review comment on a GitHub pull request with findings - logged end-to-end for cost and quality

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 table

Skills & Technologies

Amazon BedrockAmazon NovaAWS LambdaAPI GatewayAmazon SQSDynamoDBAmazon CognitoAWS WAFSecrets ManagerCloudFormationGitHub ActionsGitLab APIPython

Like what you're seeing?

I'm always up for tackling challenging infrastructure, automation, and AI/DevOps problems. Let's build something together.