CLICommands
l4 estimate
l4 estimate parses Terraform files in your workspace and estimates the monthly cost of the resources they define — entirely locally, no terraform plan required. It accepts directories, individual .tf files, or a mix.
l4 estimate
l4 estimate ./infra/
l4 estimate main.tf variables.tfFlags
| Flag | Description |
|---|---|
--region <r> | AWS region for pricing (default us-east-1) |
--gcp-region <r> | GCP region (default: auto-detect or us-central1) |
--azure-region <r> | Azure region (default: auto-detect or eastus) |
--var <key=value> | Terraform variable (repeatable) |
--var-file <path> | Terraform variable file (repeatable) |
--download-modules | Download remote modules for accurate estimates (default true) |
--out-file <path> | Save resource snapshot for later use with l4 diff |
--fail-above <amount> | Exit code 2 if monthly cost exceeds this threshold |
--format | table, json, or github-comment (default table) |
CI guardrail pattern
Fail the build when a Terraform change pushes monthly cost above $500:
l4 estimate --fail-above 500 -q ./infra/The -q (--quiet) suppresses output; the exit code is the signal. Combine with l4 diff to gate on the delta, not the absolute cost.
Saving a snapshot for later comparison
When you're not in a git repo, save the current estimate as a baseline file you can diff against later:
l4 estimate --out-file baseline.json ./infra/
# ... make changes ...
l4 diff baseline.json ./infra/In a git repo, l4 diff automatically uses the merge-base — no snapshot needed. See l4 diff.
Output formats
l4 estimate --format table # default — color-themed table
l4 estimate --format json # machine-readable
l4 estimate --format github-comment # markdown suitable for PR commentsThe github-comment format is what the LevelFour GitHub Action uses; you can post it manually with:
l4 estimate --format github-comment ./infra/ \
| gh pr comment "$PR_NUMBER" --body-file -Related
l4 diff— compare estimates between branches or against a saved baseline- GitHub Actions guide — wire
l4 estimateinto PR checks