Cost Estimation and Visibilityο
Audience: DevOps engineers and platform teams who want to understand the monthly cost of infrastructure before deploying it.
Overviewο
strata integrates with Infracost to provide cost estimates for Terraform-based deployments. Cost estimation is separate from the build pipeline β builds stay offline and deterministic.
strata build run -f deploy/prd.yaml # generates terraform (offline, no cost)
strata cost show -f deploy/prd.yaml # estimates cost (calls Infracost)
strata deploy run -f deploy/prd.yaml # deploys (also shows cost diff in --dry-run)
Prerequisitesο
Install Infracost:
# macOS
brew install infracost
# Windows
choco install infracost
# Linux / download binary
curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh
Verify the installation:
infracost --version
Infracost uses the same cloud credentials already configured in your environment (Azure CLI, AWS env vars, GCP application credentials). No extra authentication is needed.
Quick Startο
# 1. Build terraform artifacts
strata build run -f deploy/prd.yaml
# 2. Initialize terraform (required for Infracost)
cd build/production-1.0.0/terraform
terraform init
cd -
# 3. Show cost estimate
strata cost show -f deploy/prd.yaml
Example output:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π° Cost Estimate β provisioner: terraform
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Resource Monthly
βββββββββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββ
azurerm_kubernetes_cluster.aks 2,100.00
azurerm_postgresql_flexible_server.postgres 1,202.40
azurerm_container_registry.acr 200.00
azurerm_key_vault.keyvault 12.00
βββββββββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββ
Total 3,514.40
Supported Providersο
Cloud |
Support |
|---|---|
Azure |
β Full |
AWS |
β Full |
GCP |
β Full |
Hetzner |
β None |
Kamatera |
β None |
For unsupported providers, the cost command skips gracefully with no error.
Commandsο
strata cost showο
Runs infracost breakdown on terraform build artifacts and displays a cost table.
strata cost show -f deploy/prd.yaml
strata cost show -f deploy/prd.yaml --currency EUR
strata cost show -f deploy/prd.yaml --provisioner terraform
strata cost show -f deploy/prd.yaml --output json
strata cost show -f deploy/prd.yaml --refresh # bypass local cache
Results are cached in .strata/cache/cost/ for 7 days. Use --refresh to force a
fresh estimate.
A cost.json file is written alongside platform.json in the build directory
(build/{deployment}-{version}/cost.json) after each successful estimate.
strata cost diffο
Shows the cost impact of a terraform plan (how much the planned changes add or remove).
# First, create the plan JSON:
terraform -chdir=build/production-1.0.0/terraform \
plan -out=plan.tfplan
terraform -chdir=build/production-1.0.0/terraform \
show -json plan.tfplan > plan.json
# Then diff:
strata cost diff -f deploy/prd.yaml --plan-file plan.json
Example output:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π° Cost Diff
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Before: 0.00/month
After: 3514.40/month
Delta: +3514.40/month
strata cost historyο
Shows historical cost snapshots. Snapshots are recorded automatically every time
strata cost show runs successfully.
strata cost history -f deploy/prd.yaml
strata cost history -f deploy/prd.yaml --last 20
strata cost history -f deploy/prd.yaml --output json
Example output:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π° Cost History β production (last 3 snapshots)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Date (UTC) Version Monthly Delta
ββββββββββββββββββββββ ββββββββββ ββββββββββββββββ ββββββββββββ
2026-07-20 08:00:00 1.0.0 3514.40 USD β
2026-07-21 14:30:00 1.0.1 3702.20 USD +187.80
2026-07-22 10:15:00 1.0.2 3514.40 USD -187.80
History is stored at .strata/cost/{deployment}.cost-history.json (up to 50 entries).
Cost During Deploy (--dry-run)ο
When running strata deploy run --dry-run, strata automatically shows a cost diff
after the terraform plan step β if Infracost is installed and cost.json is available.
This is non-fatal: if Infracost is not installed or the cost cannot be computed, the
dry-run continues normally.
strata deploy run -f deploy/prd.yaml --dry-run
βΆ [DRY-RUN] Stage: infrastructure [terraform]
setup
check
plan
plan JSON β build/production-1.0.0/terraform.tfplan.json
π° Cost impact: 0.00 β 3514.40/month (delta: +3514.40)
Cost Policy (cost_threshold)ο
Add a cost_threshold policy to your configuration to block or warn on deployments
that exceed a monthly cost limit.
# config/configuration.yaml
spec:
policies:
# Block production deployments over β¬10,000/month
- name: prod_cost_gate
type: cost_threshold
phase: plan
enforcement: deny
configuration:
max_monthly: 10000
currency: EUR
# Warn when dev environments exceed β¬500/month
- name: dev_cost_cap
type: cost_threshold
phase: plan
enforcement: warn
configuration:
max_monthly: 500
environment_pattern: "dev*"
currency: EUR
The policy reads from the pre-computed cost.json in the build directory.
Run strata cost show before strata deploy to generate the cost file.
See Policy Types for full configuration reference.
Configuration Referenceο
Integration entry (configuration.yaml)ο
spec:
integrations:
- name: infracost
type: infracost
capabilities: [cost]
required: false # graceful degradation if not installed
validation:
command: infracost --version
min_version: "0.10.0"
authentication:
method: cli # uses existing cloud credentials
Add this to the configuration for deployments using Azure, AWS, or GCP. Infracost is
already included in the built-in azure-aks, aws-eks, and gcp-gke templates.
Troubleshootingο
Problem |
Solution |
|---|---|
|
Install Infracost: https://www.infracost.io/docs/install |
|
Run |
|
Run |
|
Check workspace YAML has a |
Estimate seems stale |
Use |
|
Run |
Provider not supported |
Infracost only covers Azure, AWS, GCP β Hetzner/Kamatera return no estimate |