Terraform · DevSecOps · Platform engineering

Know what 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.

  • 42 built-in rules
  • AWS · Azure · GCP · Kubernetes
  • Sticky PR comment + SARIF
  • Zero runtime dependencies
github-actions commented · infra#482

🔴 planlens — Risk 99/100 · CRITICAL

envs/prod · 4 critical · 6 high · Gate ❌ failed

CRITICALmodule.data.aws_db_instance.payments will be REPLACED. Existing data will not carry over.Forced by: storage_encrypted: false → true · skip_final_snapshot = true
CRITICALaws_security_group.api allows 0.0.0.0/0 on 5432 (PostgreSQL)
CRITICALaws_iam_role.github_deploy trusts OIDC subject repo:*
HIGHRenaming reports_old recreates the bucket.Fix: moved { from = … to = … }

Reviewing Terraform PRs is broken

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.

Small diff, big blast radius

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.

Scanners read code, not change

Static scanners flag config. They can't tell you that this PR turns deletion protection off, opens port 22, or replaces your prod subnet.

Try it — your plan never leaves this tab

Everything runs in your browser. No upload, no analytics, no network calls (the page's Content-Security-Policy blocks them).

Samples:
Options & .planlens.yml

Load a sample or drop your own plan to see the review.

How it works

  1. 1

    Parse

    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.

  2. 2

    Check

    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.

  3. 3

    Score

    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.

  4. 4

    Report & gate

    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.

Built for the people who approve the PR

🧠 Explains why

"Forced by storage_encrypted: false → true", destroy-then-create ordering, deletion protection that will make the apply fail.

🚚 Suggests the moved block

Detects renames, moves into modules and count index shifts, and gives you the exact HCL that keeps the existing object.

🔐 DevSecOps checks

0.0.0.0/0 on admin/DB ports, *:*, iam:PassRole on *, GitHub OIDC trust without sub, public buckets, IMDSv1, plaintext keys.

🧾 Audit-ready

SARIF and JSON as change-review evidence (ISO 27001 A.8.32, PCI DSS 6.5, SOC 2 CC8). Ignores need a written reason.

💰 Cost next to risk

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).

🧩 Org rules, no code

"No destroys in module.prod_*", "CostCenter tag required". Match on actions, type and address globs, plus attribute conditions.

🤖 Optional AI summary

Claude, OpenAI-compatible or local Ollama write a plain-English review. It only receives addresses and findings, never values, and never decides pass/fail.

🌐 Runs in any CI

GitHub Action, npx, or a Docker image for GitLab, Azure DevOps, Jenkins, Bitbucket and Atlantis. Works with OpenTofu and Terragrunt plans.

Rule catalog

Every rule can be disabled, re-rated or ignored per resource. Full reference →

Add it to your pipeline

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.sarif

Add the planlens:accept-risk label to a PR to let a reviewed risk through. The report is still posted.

Security model & FAQ

Plan JSON contains secrets. Is it safe to use this?

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.

What exactly does the optional AI summary send?

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.

How is this different from Checkov / tfsec / Trivy?

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.

Does it need cloud credentials?

No. It only reads the plan you already produced. No AWS/Azure/GCP API calls.

Does it work with OpenTofu, Terragrunt and monorepos?

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.

What about pull requests from forks?

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.