Infracost VS Code ExtensionInfracost's VS Code 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:
FeaturesSee cost estimates right above their Terraform definitions. Infracost's output updates on file save. Works with resources and modulesBoth See cost breakdownIf a simple monthly cost isn't enough for you, just click the overview to see a cost breakdown. Navigate your projects by costsSee a tree overview of your Infrastructure costs. See which projects, files and blocks have the most impact to your budget. Get started1. Install VS Code extensionOpen VS Code and install the Infracost extension. 2. Connect VS Code to InfracostOnce 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. See the Troubleshooting section if this does not work. 3. Use extensionIf you've done the prior steps correctly you'll should now see the Infracost sidebar, showing the costs of the auto-detected Terraform projects within your workspace. 4. Create a Infracost config fileWhilst the Infracost VS Code extension supports auto-detecting projects, this is normally only recommended to get up and running. To get Infracost showing accurate project costs, you'll need to add an Infracost config file at the root of your workspace. This defines the Terraform projects within your workspace and how Infracost should handle them. For example:
You can read more about how the config file works and which fields it supports by reading our dedicated documentation. When adding a config file to your workspace, it must be placed at the root directory of your workspace, and named either 5. Cost estimates in pull requestsUse 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. RequirementsThe Infracost VS Code extension requires you to have:
FAQsHow can I supply input variables to Infracost VS Code extension?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
Both HCL and JSON var files are supported, JSON var files must include a How do I supply a usage file to the Infracost VS Code extension?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:
I see a lot of resources showing $0.00 costs, why is this?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. How can I configure the currency Infracost uses?If you have the
Infracost supports all ISO 4217 currency codes. This FAQ has more details. TroubleshootingKnown Issues
Locating Infracost error logsIf 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:
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 VS Code workspace size. ContributingWe love any contribution, big or small. If you want to change the Infracost VS Code extension, we recommend you use VS Code to build and develop the extension locally.
Once you're finished with your work, open a PR, and we'll be happy to review it as soon as possible. |