The plan is unreadable
2,000 lines of plan output in a CI log. Reviewers skim the HCL diff, approve, and miss # must be replaced.
Terraform · DevSecOps · Platform engineering
terraform apply will really do.planlens reviews the plan, not the code. It catches destroyed databases, forced replacements, opened security groups and widened IAM in your pull requests, so you see them before production does.
🔴 planlens — Risk 99/100 · CRITICAL
module.data.aws_db_instance.payments will be REPLACED. Existing data will not carry over.Forced by: storage_encrypted: false → true · skip_final_snapshot = trueaws_security_group.api allows 0.0.0.0/0 on 5432 (PostgreSQL)aws_iam_role.github_deploy trusts OIDC subject repo:*reports_old recreates the bucket.Fix: moved { from = … to = … }2,000 lines of plan output in a CI log. Reviewers skim the HCL diff, approve, and miss # must be replaced.
A renamed resource, a reordered count list or one changed attribute destroys and recreates a database. The diff looks harmless; only the plan shows it.
Static scanners flag config. They can't tell you that this PR turns deletion protection off, opens port 22, or replaces your prod subnet.
Everything runs in your browser. No upload, no analytics, no network calls (the page's Content-Security-Policy blocks them).
.planlens.ymlLoad a sample or drop your own plan to see the review.
Reads terraform show -json (or the binary plan). It normalizes creates, updates, destroys, replaces, imports, moves and drift, and records which attribute forced each replacement.
42 rules look at what this plan introduces: data loss, blast radius, refactor mistakes, network exposure, IAM widening, disabled safeguards, plaintext secrets and (with Infracost) cost. Your own rules go in YAML.
A 0–100 risk score and a level per plan. Accepted risks need a reason and can expire, so exceptions don't become permanent debt.
A sticky PR comment, SARIF for the Security tab, inline annotations on the .tf line, a job summary and JSON. The exit code blocks the merge.
"Forced by storage_encrypted: false → true", destroy-then-create ordering, deletion protection that will make the apply fail.
moved blockDetects renames, moves into modules and count index shifts, and gives you the exact HCL that keeps the existing object.
0.0.0.0/0 on admin/DB ports, *:*, iam:PassRole on *, GitHub OIDC trust without sub, public buckets, IMDSv1, plaintext keys.
SARIF and JSON as change-review evidence (ISO 27001 A.8.32, PCI DSS 6.5, SOC 2 CC8). Ignores need a written reason.
Feed it your Infracost JSON to show the monthly cost delta in the same PR comment, and gate on a budget (cost.max_monthly_increase).
"No destroys in module.prod_*", "CostCenter tag required". Match on actions, type and address globs, plus attribute conditions.
Claude, OpenAI-compatible or local Ollama write a plain-English review. It only receives addresses and findings, never values, and never decides pass/fail.
GitHub Action, npx, or a Docker image for GitLab, Azure DevOps, Jenkins, Bitbucket and Atlantis. Works with OpenTofu and Terragrunt plans.
Every rule can be disabled, re-rated or ignored per resource. Full reference →
permissions:
contents: read
pull-requests: write # sticky PR comment
security-events: write # SARIF → Security tab
steps:
- run: terraform plan -out=tf.plan && terraform show -json tf.plan > plan.json
working-directory: infra
- uses: yousafkhamza/planlens@v1
with:
plan: infra/plan.json
source-dir: infra # annotate the exact .tf line
fail-on: high
- uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: planlens.sarifAdd the planlens:accept-risk label to a PR to let a reviewed risk through. The report is still posted.
# no install needed (Node ≥ 20)
npx planlens plan.json
# binary plans are converted automatically
npx planlens tf.plan --fail-on critical
# many workspaces, several outputs at once
npx planlens envs/*/plan.json \
--format markdown -o comment.md \
--out sarif=planlens.sarif --out json=planlens.json
# exit codes: 0 passed · 1 gate failed · 2 usage/input error# Jenkins, Azure DevOps, Bitbucket, Atlantis — anything that runs containers
docker run --rm -u "$(id -u)" -v "$PWD:/work" ghcr.io/yousafkhamza/planlens:1 \
plan.json --fail-on high \
--out markdown=planlens.md --out sarif=planlens.sarif
# with a cost estimate
infracost breakdown --path plan.json --format json --out-file infracost.json
docker run --rm -v "$PWD:/work" ghcr.io/yousafkhamza/planlens:1 plan.json --infracost infracost.jsonMulti-arch (amd64/arm64), runs as non-root, and ships with an SBOM and provenance.
planlens:
stage: review
image: node:22-alpine
needs: [plan]
script:
- npx --yes planlens@1 plan.json --fail-on high
--out markdown=planlens.md --out sarif=planlens.sarif
artifacts:
when: always
paths: [planlens.md, planlens.sarif]fail_on: high
stateful_types: ["mongodbatlas_cluster"]
severity_overrides:
PL204: high
ignore:
- rule: PL201
address: "module.edge.aws_security_group.public_alb"
reason: "Public ALB by design, fronted by WAF (SEC-1234)"
expires: 2027-06-30
rules:
- id: ORG001
title: No destroys in production modules
severity: critical
when:
actions: [delete, replace]
address: "module.prod_*"Yes. Terraform plan JSON includes sensitive values in plain text (only marked as sensitive). planlens never prints values that Terraform marks sensitive, never sends plan data anywhere, and this web page runs fully offline in your browser. In CI it runs on your runner. The only network call it ever makes is the PR comment to your GitHub API, plus the optional AI summary if you turn it on.
Resource addresses, action types (create/replace/…), names of changed attributes and the finding messages. Account IDs, emails and IPs are masked. Attribute values are never sent. Use ai: ollama to keep everything on your network. The AI can't change the pass/fail result.
Those scan your code for misconfigurations, and they're great. planlens reviews the change: what gets destroyed or replaced and why, what this PR newly exposes, and whether a rename recreates your database. Use both.
No. It only reads the plan you already produced. No AWS/Azure/GCP API calls.
Yes. The plan JSON format is the same; binary plans are converted with terraform or tofu. Pass several plans or a glob, and each gets its own section, with one combined gate.
Fork PRs get a read-only token, so planlens can't comment. It still writes the job summary, annotations and SARIF, and tells you how to fix the permissions.