Feb 2021: Faster runs, new resources and Atlantis!

Here’s what we released in February – big thanks to the community contributors! You can upgrade to the latest version (v0.7.20) to pickup these goodies:

🚀 Speed improvements

The CLI now only runs terraform init if required since Terraform commands aren’t the fastest in the world (init usually takes 20+ secs for me, but it depends on how many plugins you have). Furthermore, calls to the Cloud Pricing API have been switched from sequential to parallel. Infracost should run much faster than before.

⚙️ Config file

Depending on your Terraform workflow, you’ll run Infracost with different options. Things can get complicated when you have multiple projects in a repo, each requiring their own Terraform variables. For example, if you have two workspaces and want to see their total cost estimate, you would run something like this:

terraform workspace select dev
infracost breakdown --path code --format json \
--terraform-plan-flags "-var-file=env.dev.tfvars" > dev.json

terraform workspace select prod
infracost breakdown --path code --format json \
--terraform-plan-flags "-var-file=env.prod.tfvars" > prod.json

infracost output --format table --path dev.json --path prod.json

You can now create an infracost.yml config file in your repo to describe your setup, then just run infracost --config-file infracost.yml.

🌎 Atlantis integration

Infracost now integrates with Atlantis, which is a popular CI/CD tool that enables Terraform pull request automation.

🗒️ Diff functionality in JSON output

You can now get the monthly cost diff from the Infracost JSON output, e.g. the following shows the monthly cost is going to be increased by $1530 if the Terraform plan is applied. You can also get totalHourlyCost, or add --no-color=true --log-level=warn if you don’t want the spinners/logs/color.

infracost breakdown --path=. --format=json | jq '[.projects[].diff.totalMonthlyCost | select (.!=null) | tonumber] | add'

⛅ New cloud resources

We also shipped support for the following cloud resources:

  • AWS: Config, ECS on EC2, EventBridge, Route 53 Resolver, CodeBuild
  • Google: Key Management Service (KMS), Google Cloud Functions
  • Azure: great progress is being made, stay tuned for exciting news soon

The usage file params for Google Cloud Functions are pretty cool; as shown below you can define 3 simple params and we’ll estimate the cost for you, no need for you to decode how function memory maps to GHz-seconds and rounding.

request_duration_ms: 150 # milliseconds
monthly_function_invocations: 10000000
monthly_outbound_data_gb: 50
NAME                              MONTHLY QTY  UNIT         MONTHLY COST

├─ CPU 800,000 GHz-seconds 8.0000
├─ Memory 500,000 GB-seconds 1.2500
├─ Invocations 10,000,000 invocations 4.0000
└─ Outbound data transfer 50 GB 6.0000
Total (USD) 19.2500

As always, looking forward to your feedback (hello@infracost.io).

Similar Posts