Infracost VSCode Extension
Infracost's VSCode extension shows you cost estimates for Terraform right in your editor! Prevent costly infrastructure changes before they get into production.
This helps with a few use-cases:
- Compare configs, instance types, regions etc: copy/paste a code block, make changes and compare them.
- Quick cost estimate: write a code block and get a cost estimate without having to use AWS, Azure or Google cost calculators, or read the long/complicated pricing web pages.
- Catch costly typos: if you accidentally type 22 instead of 2 as the instance count, or 1000GB volume size instead of 100, the cost estimate will immediately pick that up and let you know.
See cost estimates right above their Terraform definitions. Infracost's output updates on file save.
Works with resources and modules
module blocks are supported. 3rd party module blocks are also supported!
See cost breakdown
If a simple monthly cost isn't enough for you, just click the overview to see a cost breakdown.
Navigate your projects by costs
See a tree overview of your Infrastructure costs. See which projects, files and blocks have the most impact to your budget.
1. Install VSCode extension
Open VSCode and install the Infracost extension.
This will also install the the Hashicorp Terraform extension extension if you don't already have it.
2. Connect VSCode to Infracost
Once you've installed the extension, you'll need to connect to your editor to your Infracost account. Click the "connect to Infracost" button in the Infracost sidebar.
This will open a browser window where you'll be able to log in to Infracost Cloud and authenticate your editor.
3. Use extension
Navigate to any Terraform file, if you've done the prior steps correctly you'll see costs above supported blocks.
4. Cost estimates in pull requests
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.
The Infracost VSCode extension requires you to have:
How can I supply input variables to Infracost VSCode extension?
To supply input variables for your Terraform projects, you must include a var file called
terraform.tfvars at the root level of your Terraform project.
Alternatively, you can use several files with the suffix
prod.auto.tfvars. Both HCL and JSON var files are supported, JSON var files must include a
How can I configure the currency Infracost uses?
To set the currency, run
infracost configure set currency EUR (or any other ISO 4217 currency code). This FAQ has more details.
When opening a workspace with a large number of Terraform projects for the first time. Infracost will evaluate all the projects and download any required modules. This means
that it might take some time before pricing information is available. If you're worried that Infracost VSCode extension isn't working in your workspace but haven't got
any error messages, it is likely that Infracost is still indexing your workspace. The extension has a status bar on the right-hand side of the editor which will show a loading state
when Infracost is running.
Terragrunt is not supported. Follow this issue for more information for future updates about Terragrunt support.
Infracost usage files are not yet supported. This means that resources that solely use usage costs will have a
0.00 cost shown:
Follow this issue to receive updates on usage file support.
Diff functionality is not yet supported. Follow this issue to receive updates on diff support.
VSCode Infracost does not yet work with Infracost config files. Multi project support is available using Infracost native auto-detection.
This means that the first time running in a multi-project workspace might be quite slow. Follow this issue to receive updates on config file support.
Locating Infracost error logs
If you're having problems with the extension and your problem isn't any of the known issues above, you can find the Infracost extension logs using the following method:
- Open the extension terminal using the top menu (Terminal->New Terminal)
- Select Output and Infracost Debug from the dropdown.
- There are sometimes additional CLI logs hidden in the log (Window) output.
The log there might give you more information for a problem you can fix on your own, e.g. syntax errors. If it's something more ominous please raise an issue, so that we can identify and fix the problem. Please include as much of the log information as you can and any other helpful information like OS and VSCode workspace size.
We love any contribution, big or small. If you want to change the Infracost VSCode extension, we recommend you use VSCode to build and develop the extension locally.
- Clone the repo.
yarn install all the dependencies.
- Open the repo in VSCode.
- Install the Terraform VSCode extension in VSCode.
- Inside the editor, press F5. VSCode will compile and run the extension in a new Development Host window.
- Open a Terraform project, and navigate to a valid file. If all the previous steps have been followed correctly, you should see Infracost cost estimates above supported resource blocks.
Once you're finished with your work, open a PR, and we'll be happy to review it as soon as possible.