June 2022: The Most Significant Update To Infracost To Date!
Back in February, we started an ambitious journey: remove our dependency on the Terraform CLI by parsing code directly! We’re excited to announce Infracost v0.10, which completes that journey 🎉
Infracost is now much faster, simpler to add to CI/CD, and does not need cloud creds since a Terraform plan is not required.
Infracost v0.10
Checkout the migration guide to upgrade. The experimental --terraform-parse-hcl
flag has been removed and going forward, Infracost can be run in two ways via --path
:
- Parsing HCL code (directory): the default and recommended option as it has the following 5 benefits.
# Terraform variables can be set using --terraform-var-file
# or --terraform-var
infracost breakdown --path /code - Parsing plan JSON file: this will continue to work as before.
cd /code
terraform init
terraform plan -out tfplan.binary
terraform show -json tfplan.binary > plan.json
infracost breakdown --path plan.json
1. Faster CLI
Removing the need for terraform init
and terraform plan
means a super-fast CLI: Infracost used to take around 50 seconds to run on our internal Terraform mono-repo, that’s now reduced to 2 seconds 🚀
2. No cloud creds needed
Removing our dependency on the Terraform CLI means you no longer need to set cloud credentials or Terraform secrets, which simplifies CI/CD integrations too.
3. Cost of TF modules
Not needing cloud creds/secrets or a Terraform plan means you can now generate cost estimates from Terraform modules. It also enables cost estimates to be put in Infra-as-Code repo readmes and Visual Studio!
To make infracost diff
work without a plan, we introduced a new --compare-to
flag so git-based cost diffs can be produced:
git checkout main
infracost breakdown --path /code --format json \
--out-file infracost-base.json
git checkout my-branch
infracost diff --path /code --compare-to infracost-base.json
4. Compare Infracost runs
The infracost diff
command can now also be used to compare Infracost runs to see what’s changed between historic runs:
infracost diff --path infracost-today.json \
--compare-to infracost-last-week.json
5. Detect multi-project repos
Setting the --path
flag to a top-level repo directory will now attempt to process all projects automatically. If this does not work for your use-case, use a config-file.
New resources
We added support for the following cloud resources and identified many more free resources:
- AWS: Support for reservation in
db_instance
- Google:
google_compute_per_instance_config
,google_compute_region_per_instance_config
Community
Many thanks to @golgeek and @carmeloriolo for your contributions. Also shout-out to the following people for sharing their Infracost knowledge with the rest of the community. InfraSocks are coming your way!
- Neil Shah: 5 Best Terraform Tools That You Need in 2022
- George Abuzo: How to estimate infrastructure cost using infracost
- Anton Bakavets: Terragrunt CI/CD Pipeline с использованием Infracost. Что такое Infracost. GitHub Actions
- Everyone who joined our May community call
👉 Join our community call on Wednesday 8 June to discuss v0.10, the Visual Studio Code extension, and our upcoming dashboard that provides visibility of cost estimates across projects.