CLICommands
l4 diff
l4 diff shows the cost delta between your current Terraform state and a baseline. By default the baseline is the git merge-base (main or master); you can also point it at a saved snapshot file.
l4 diff main.tf
l4 diff ./infra/
l4 diff --base main ./infra/
l4 diff baseline.json ./infra/The default baseline comes out of git history, and both GitHub Actions and GitLab CI check out a shallow clone, which leaves no merge-base to compare against. CI/CD integration sets the checkout depth each runner needs. Without history, diff against a saved baseline instead.
Flags
| Flag | Description |
|---|---|
--base <ref> | Git ref to diff against (default: auto-detect main or master) |
--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) |
--fail-above <amount> | Exit code 2 if monthly delta exceeds this threshold |
--format | table, json, or github-comment (default table) |
Global flags (--json, --jq, --template, --quiet, --token, --api) apply. See CLI overview.
CI gate
Fail the build when a pull request adds more than $100 a month:
l4 diff --fail-above 100 -q ./infra/Over the threshold l4 diff exits 2 (ExitIssuesFound), which a job can tell apart from the 1 a generic failure returns. Exit codes has the full set.
Comparing against a saved baseline
Outside a git repository, or while you stage a multi-step deployment, diff against a snapshot that l4 estimate --out-file wrote earlier:
l4 estimate --out-file baseline.json ./infra/
# ... make changes ...
l4 diff baseline.json ./infra/Posting to a pull request
--format github-comment emits Markdown you can pipe into a comment:
l4 diff --base main --format github-comment ./infra/ \
| gh pr comment "$PR_NUMBER" --body-file -Related
l4 estimate: the absolute monthly cost, and the--out-filesnapshot this command reads- CI/CD integration: the GitHub Actions and GitLab CI jobs that run
l4 diffon a pull request - Output formats:
--json,--jq,--templateand--quiet