Compare

Build your own vs Stategraph

CI jobs, a bucket, a lock table, and a comment step work until two pull requests touch the same state. Stategraph puts a database under that pipeline, and runs the pull request layer if you want.

Teams running Terraform on Stategraph

Zip logo PrizePicks logo Haus logo Avaloq logo Xanadu logo January logo Patients Know Best logo NOV logo Mixpanel logo Notable Health logo Skool logo

Read the case studies →

How Stategraph is better

1. The pull request layer

Maintained by you, or included

On a state file, the lock table, comment step, approvals, drift, and cost are small systems you keep working. Stategraph Orchestration includes them.

Discover Orchestration →
Build your own
what you maintain
✗ a lock table, one apply at a time ✗ a comment script on the GitHub API ✗ approval rules in three places ✗ a drift cron job and a notifier ✗ a cost tool you wire in
Stategraph Orchestration
included
✓ resource locks, parallel applies ✓ plan, cost, approval in one comment ✓ approvals per directory, CODEOWNERS ✓ drift detection on a schedule ✓ cost thresholds in the pull request

Illustrative. Each line on the left is a job you keep working.

2. Plan and lock scope

Sized to the change, not the state

A CI job on a state file refreshes every resource and locks the whole file, and no script changes that. Stategraph plans the part of the graph your change reaches and locks only those resources.

Learn about parallel applies →

No-op plan on a real 800 MB production state, and each apply's lock.

terraform plan
3+ hours
Refreshes every resource
stategraph plan
97 seconds
Walks only the change
lock table
Whole file
One apply at a time
resource locks
Per resource
Disjoint changes apply together

One benchmark. Results vary with the shape of the state.

3. Query

SQL over your infrastructure

A pipeline leaves a state file in a bucket. Stategraph parses state into PostgreSQL, so inventory, blast radius, and who changed what are one query.

How you can query state →
stategraph · sql
❯ stategraph query "SELECT type, COUNT(*) FROM resources GROUP BY type ORDER BY COUNT(*) DESC LIMIT 5" type count kubernetes_role_binding 586 kubernetes_manifest 382 null_resource 317 kubernetes_service 175 google_kms_key_ring 166

Real output captured from a live Stategraph instance.

4. Your pipeline

Keep the pipeline, add the database

Your workflow YAML, triggers, and secrets stay. Stategraph goes under them: export three variables and replace two commands.

GitHub Actions guide →
github actions workflow
env: STATEGRAPH_API_BASE: https://stategraph.example.com STATEGRAPH_API_KEY: ${{ secrets.STATEGRAPH_API_KEY }} STATEGRAPH_TENANT_ID: your-tenant-id # on pull_request - run: stategraph plan # on push to main - run: stategraph apply --auto-approve

GitHub Actions. GitLab CI, Jenkins, and CircleCI follow the same pattern.

Side by side

Build your own vs Stategraph: Key differences

Capability Stategraph Build your own
Plan scope ✓Only the affected subgraph ✗The whole file, every run
Lock scope ✓The resources a change touches ✗The whole file, one apply at a time
Two pull requests, one state ✓Both apply unless they overlap ✗The second waits, or merges a stale plan
A change across states ✓One atomic transaction ✗Sequential jobs, partial failure is yours
Query your infrastructure ✓SQL across every resource and state ✗Grep the JSON, one file at a time
Approvals ✓Per directory, with CODEOWNERS routing ●Branch protection, one rule for the repository
Policy ✓OPA, Conftest, and Checkov gates, with a named override ●A Conftest step you write, no override
Drift detection ✓Scheduled, in a maintenance window ✗A cron job and a notification script
Cost ✓Delta in the plan, thresholds in the pull request ✗An external tool you wire in

The last four rows are Stategraph Orchestration, on the same database.

Same HCL, new commands

How to switch

from a state file to Stategraph
# 1. See how your repo fits. Local, no API calls, no upload. ❯ stategraph diagnostics run # 2. Import one state and its HCL. Modules and providers do not change. ❯ stategraph import tf # 3. Replace two commands in your CI, or let Orchestration run them ❯ stategraph plan ❯ stategraph apply # To leave: write a state file back ❯ stategraph states export

“We wanted to put some control and some process around that. It was no longer kind of acceptable to just be doing a Terraform plan and apply on our CLI, on our workstations.”

Stewart Baillie, DevOps Engineer at Integrated Marine Observing System · Read the case study →

FAQ

Common questions

Try it with your own state

Import a state file and run your first plan in under 30 minutes. Pro is free for 30 days, no credit card.