Skip to main content

October 2021: Improved CLI output, faster runs & fetch from CloudWatch

· 3 min read

We released Infracost v0.9.12 recently, you can upgrade to use these features. This release includes many bug fixes and we have made Infracost a lot faster to run!

Improved CLI output

We've simplified the output for AWS S3 and CloudFront. Previously these resources had over 50 lines of output due to their complicated pricing models. We now only output their standard pricing options; other prices are shown when applicable parameters are used in a usage file.

Furthermore, when a new usage file is generated, values are commented-out unless a value is fetched from AWS CloudWatch. This enables you to uncomment required usage-based parameters. Also, cost components with zero usage are hidden in the table and HTML output to simplify the output.

The diff output now groups projects with no usage diffs into one line, which can simplify the output for Terraform mono repos and Terragrunt projects.

The JSON output now includes 4 new fields: the hourly/monthly total cost of all diffs and past totals. This is useful when Infracost is used with other tools such as pre-commit-terraform.

Faster CLI runs

To speed-up CLI runs, we now cache Terraform plans where possible. This is helpful when the CLI is re-run to do what-if analysis with the usage file or show skipped resources. Caching only happens when the CLI is being used outside of CI/CD integrations and a new --no-cache flag has been added to disable this behavior where required.

Usage-based resources

The fetch from CloudWatch feature has been expanded to fetch usage data for S3, AutoScaling and EKS node groups. A new CI/CD parameter, sync_usage_file=true, has been added so this can also be triggered in CI/CD runs.

Multi-project runs

Infracost config files now support a new env parameter that can be used to define environment variables for each project as shown in the following example. The config file syntax is also validated and more helpful error messages are shown. We recommend users add an infracost.yml config file to their projects as well as any usage files to their repos so infracost breakdown --config-file infracost.yml can be run by anyone without having to type all the flags/envs.

version: 0.1
projects:
- path: dev
usage_file: dev/infracost-usage.yml
env:
AWS_PROFILE: infracost-dev
AWS_ACCESS_KEY_ID: ${DEV_AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${DEV_AWS_SECRET_ACCESS_KEY}
- path: prod
usage_file: prod/infracost-usage.yml
...

New resources

We have added support for the following resources: aws_dx_connection, aws_mwaa_environment, aws_directory_service_directory, azurerm_synapse_spark_pool, azurerm_synapse_sql_pool and azurerm_synapse_workspace.

Community

The community has been writing some awesome content around Infracost, and I'd like to give them a shout-out here:

  • Florian Pialoux wrote a blog on how to integrate Infracost with Terraform Cloud.

  • Anton Babenko, Maxym Vlasov and George Yermulnik added support for Infracost to pre-commit-terraform, checkout the docs for useful tips.

  • Alex McFarland wrote a step by step guide on Infracost.

Finally, Vadim joined our team, and I gave a lightning talk at HashiConf. My talk included details of use-cases we're seeing and a demo of the new Terraform Cloud RunTasks integration.

Up next!

We're focusing on CI/CD integrations and would love to see your upvotes on the ideas mentioned in the GitHub discussion. Checkout our project board to see what else is in flight.

It's been awesome to hear your feedback. Message me on Slack or Twitter if you have any questions!