Skip to main content

HashiCorp Terraform Cost Estimation with Infracost and Run Tasks now GA

· 3 min read

Today, I’m super excited to announce, alongside our partner HashiCorp, that we have launched a direct integration into Terraform Cloud using the new Terraform run tasks feature.

Hashicorp Terraform Run Tasks now generally available to all

We started Infracost to show engineers how their Infrastructure as Code changes will impact cloud costs before anything goes to production. It felt unfair not to have a ‘checkout screen’ for developers because when budgets were breached, they would not only be blamed but also be tasked with bringing costs down (again, with no indication of whether their changes are having the right cost impact).

We didn’t want to create something that would slow engineers down. They want to ship great and efficient products fast. So we brought costs directly into the workflow by integrating into CI/CD systems. Infracost now leaves a comment like ‘this change will increase your costs by 15% next month’ with a detailed breakdown.

Today, I’m super excited to announce, alongside our partner HashiCorp, that we have launched a direct integration into Terraform Cloud using the new Terraform run tasks feature. If you are using Terraform Cloud, you can show everyone a cost estimate of the infrastructure changes without leaving the TFC dashboard. The setup takes 3 minutes.

The 3 minute setup - start here

  1. Log into Terraform Cloud > go to Settings (top menu) > Run tasks (left menu) > Create run task (button top right).
step 1 - Create a Terraform Run Task
  1. Go to https://dashboard.infracost.io/tfc-sign-up and enter your name and email address to get an Infracost API key.
step 2 - Create an Infracost API key
  1. Enter the Endpoint URL and the HMAC key from step 2 into Terraform Cloud (step 1). Give the Run Task a name like ‘Infracost cost estimation’.

  2. Now we need to add a Run Task to a Workspace in Terraform Cloud, so go to Workspaces (top menu) > select your workspace > Settings > Run Tasks, and click the (+) button next to the ‘Infracost cost estimation’ Run Task that you just created.

step 3 - Add Run Tasks to workspaces
  1. Select ‘Advisory’ as the enforcement level - this means that the cost estimation does not block a run from competing. Infracost does not yet support Mandatory enforcement in which a run can be blocked due to increased costs, but this will be a feature in the future.

  2. Click Create. That’s it. You are now showing everyone how the TF code changes will impact cloud costs. You can now add Infracost to as many workspaces as you like.

You can get up and running with Terraform Run Tasks and Infracost within a few minutes. Here is a live walkthrough of Terraform Run Tasks with Infracost: