README.md1.7 KB
View on GitHubhooks-infracost
Demonstrates the infracost hook kind: an after.terraform.plan hook
that runs an Infracost-compatible command against the component and renders a
cost summary in the terminal.
What this shows
kind: infracostusing the same hook args, output file, failure mode, and result handler as real Infracost.dependencies.tools.infracostpins and installs the real Infracost CLI.- Single markdown rendering used everywhere: when Atmos Pro is connected
the same body is uploaded; in the terminal it renders via
ui.Markdown().
Requirements
- Terraform on PATH.
INFRACOST_API_KEYin your shell (free at https://www.infracost.io/).- No AWS credentials needed — the component uses dummy AWS provider
config so
terraform plansucceeds offline.
Infracost needs its API key to access its cloud-hosted pricing database. Atmos installs the pinned CLI automatically before the hook runs.
Run
export INFRACOST_API_KEY=... # https://www.infracost.io/atmos terraform plan nat-gateway -s test
Expected: terraform plan succeeds; the after.terraform.plan hook fires; the
real Infracost CLI prices the configuration and Atmos prints a markdown cost
summary showing the NAT gateway and EIP monthly costs.
Files
atmos.yaml— Atmos config.stacks/deploy/test.yaml— stack with a single component and one hook.components/terraform/nat-gateway/— minimal NAT gateway + EIP module.
Notes
subnet_id is a placeholder ID. We don't need a real subnet because we
never apply — infracost prices resources from HCL/plan, not from live state.