Infracost is an IntelliJ-based plugin that allows you to shift left on your Cloud costs by providing cost estimates for your Terraform code.
Infracost is a companion to the Infracost CLI and provides a way to view cost estimates directly in your IDE.
- View cost estimates for your Terraform code directly in your IDE
- Supports all JetBrains IDEs
- Supports all Terraform providers
You can install the plugin from the JetBrains Plugin Repository.
- Open the IDE and go to
Settings
->Plugins
->Marketplace
- Search for
Infracost
- Click
Install
- Restart the IDE
- Open a Terraform file and click on the
Infracost
tab at the bottom of the IDE - Click on
Refresh
to get the cost estimate - Use our CI/CD integrations to add cost estimates to pull requests. This provides your team with a safety net as people can understand cloud costs upfront, and discuss them as part of your workflow.
To supply input variables for your Terraform projects, we recommend you add a config file. Config files allow you to add any number of variable files for defined projects. Infracost also auto-detects any var files called terraform.tfvars
, or *.auto.tfvars
at the root level of your Terraform projects. e.g:
version: 0.1
projects:
- path: dev
name: development
usage_file: dev/infracost-usage.yml
terraform_var_files:
- dev.tfvars
- global.tfvars
Both HCL and JSON var files are supported, JSON var files must include a .json
suffix.
To supply input variables for your Terraform projects, we recommend you add a config file. Config files allow you to define a usage file for each project you specify, e.g:
version: 0.1
projects:
- path: dev
usage_file: dev/infracost-usage.yml
- path: prod
usage_file: prod/infracost-usage.yml
These resources are likely usage-based resources. For example, AWS Lambda is billed per request, so unless you specify the number of requests that the function receives. You're likely to see a message similar to the following: " Cost depends on usage: $0.20 per 1M requests" in the resource breakdown.
To specify usage for resources, add a usage file and reference it in a config file you add at the root of your workspace.
If you have the infracost
CLI installed, you can set the currency by running infracost configure set currency EUR
(check infracost configure --help
for other configuration options). Otherwise, update the global infracost configuration file (found at ~/.config/infracost/configuration.yml
) with the following:
version: "0.1"
currency: EUR
Infracost supports all ISO 4217 currency codes. This FAQ has more details.