Skip to main content

v0.8 migration guide

Once you've installed Infracost v0.8, follow this page to migrate to use the new features. Whilst we tried hard not to break old functionality by adding deprecation warnings, there is the risk of breakage as these improvements required significant code changes. Please report any issues and we'll address them as soon as possible.

What's new?

🚀 Infracost v0.8.0 included major improvements to the CLI:

New diff command

A new infracost diff command has been added to show a diff of monthly costs between the current and planned state. This was requested by many users as we already provided similar functionality in our CI/CD integrations, but it wasn't available in the CLI, and the CI output could be confusing. We've addressed both issues by adding this new command.

Infracost diff command

Simplified table output

The dashes (-) have been replaced with price descriptions such as Cost depends on usage: $0.20 per 1M requests so you can understand the pricing structure of usage-based resources such as AWS Lambda or Google Cloud Storage.

Infracost breakdown command

Simplified inputs

A new path flag has been introduced to replace the various methods of running Infracost. You can now simply point Infracost to the path of a Terraform directory, plan binary file, or plan JSON file and it'll just work. This lays some of the groundwork for supporting other IaC tools in the future 😉

Simplified config file

The config file has been updated to support infra-as-code repos that have multiple workspaces and projects. This command combines the projects into the same breakdown or diff output. So if a Terraform module or variable is used across workspaces/projects, you can quickly see the cost impact of changing it.

Migration guide

Commands

Root command

The root infracost command has been deprecated as we've moved to using subcommands:

  • infracost breakdown: this works similarly to the previous infracost root command and shows a table breakdown of all resources by default. Run infracost breakdown --help to see the other options.
  • infracost diff: this shows a list of the resources along with costs that will change when the Terraform plan is applied.

The old root command will be fully removed in v0.9.0.

Report command

The infracost report command has been deprecated and replaced with infracost output.

This takes Infracost JSON files as inputs via --path and allows them to be combined and outputted in any format using --format json|diff|table|html. This command can be used with wildcards too, e.g. infracost output --format html --path "infracost*.json" > output.html.

Flags

The following flags have all been deprecated and replaced with --path:

  • --terraform-dir / --tfdir
  • --terraform-json-file / --tfjson
  • --terraform-plan-file / --tfplan

The --output/ -o flag has been replaced with --format.

Environment variables

The following environment variables have been deprecated:

  • TERRAFORM_BINARY: replaced with INFRACOST_TERRAFORM_BINARY
  • TERRAFORM_CLOUD_HOST: replaced with INFRACOST_TERRAFORM_CLOUD_HOST
  • TERRAFORM_CLOUD_TOKEN: replaced with INFRACOST_TERRAFORM_CLOUD_TOKEN
  • SKIP_UPDATE_CHECK: replaced with INFRACOST_SKIP_UPDATE_CHECK

Config file

The format of the config file has been simplified and a new version parameter has been introduced to enable safer iterations in the future. Initially the config file can be used for supporting repos that have multiple workspaces or projects. See the config file docs for details.

version: 0.1
projects:
- path: path/to/my_terraform
terraform_workspace: dev

- path: path/to/my_terraform
terraform_workspace: prod

The following top-level keys in the old config format have been removed: log_level, no_color outputs. These can be set using flags (--log-level, --no-color and --format / --show-skipped). If you were using multiple outputs you can use the infracost output command to perform the same functionality, e.g.:

infracost breakdown --path=path/to/code --format=json > infracost_breakdown.json
infracost output --path=infracost_breakdown.json --format=table
infracost output --path=infracost_breakdown.json --format=diff

In the future we may add these keys back into the config format, but need to better handle edge cases when these are used in combination with flags and environment variables.

JSON output

The JSON output from infracost breakdown --format json has been changed to the following format:

{
"version": "0.1",
"projects": [
{
"path": "path/to/code",
"metadata": {
"terraformWorkspace": "stage",
},
"pastBreakdown": {
"resources": [...]
"totalMonthlyCost": "730",
"totalHourlyCost": "1"
},
"breakdown": {
"resources": [...]
"totalMonthlyCost": "1460",
"totalHourlyCost": "1"
},
"diff": {
"resources": [...]
"totalMonthlyCost": "730",
"totalHourlyCost": "1"
}
}
],
"summary": {
"unsupportedResourceCounts": {...}
},
}

The following top-level keys in the old JSON format are deprecated and will be removed in v0.9.0: resources, totalMonthlyCost, totalHourlyCost. The resourceSummary > unsupportedCounts key has been renamed to summary > unsupportedResourceCounts.

CI/CD integrations

Follow the relevant sections below to upgrade your CI/CD integration.

GitHub Actions

Switch your GitHub Action config to use our v0.6.0 GitHub Action. This supports the new path or config parameters as mentioned above and in the GitHub Actions readme.

The GitHub Action outputs default_branch_monthly_cost and current_branch_monthly_cost have been removed, and replaced with past_total_monthly_cost and total_monthly_cost.

GitLab CI

Switch your GitLab CI config to use the latest version of our template. This supports the new path or config parameters as mentioned above and in the GitLab CI readme.

CircleCI

Switch your CircleCI Orb to use our v0.6.0 Orb. This supports the new path or config parameters as mentioned above and in the Orb readme.

Bitbucket Pipelines

Update your Bitbucket pipeline config to use the example in the latest Pipeline readme. This supports the new path or config parameters as mentioned above.

Atlantis

Both Atlantis integration methods now run infracost diff using the $PLANFILE that Atlantis generates.

If you used the Docker image before, please update to the latest infracost-atlantis Docker image, or build your own image using the instructions mentioned here. The terraform_plan_flags environment variable is no longer needed, so remove that from your Atlantis config.

If you used the Infracost API, no changes are needed as the API has been updated to return a diff.