HashiCorp : Terraform Cloud

Advanced Topics

Lab Solution Cost Estimation

Terraform Cloud Cost Estimation provides real-time insights into the financial impact of your infrastructure-as-code changes. By previewing estimated cost deltas before you apply a plan, you can budget effectively and avoid surprises in your cloud bill.

Prerequisites

Note

Cost Estimation is available in the Team & Governance tier of Terraform Cloud. If you’re not on this tier yet, start a free trial to enable cost forecasting features.

1. Enable Cost Estimation

  1. Navigate to Settings > Plan & Billing in your Terraform Cloud organization to confirm your Team & Governance tier and trial status.
    The image shows a "Plan & Billing" page for Terraform Cloud, indicating a free trial with premium features and a note that the plan will change to free on October 29th, 2022. It also mentions that there are no invoices yet.

  2. Next, go to Settings > Cost Estimation Integration, enable cost estimation for all workspaces, and click Update Settings.
    The image shows a settings page for "Cost Estimation" in a software interface, with an option to enable cost estimation for all workspaces and a button to update settings.

2. Viewing Cost Estimates

After enabling the feature, open any workspace (for example, MyAppDev) and trigger a plan. The Cost Estimation stage appears immediately after the Terraform plan phase:

The image shows a Terraform Cloud interface displaying a cost estimation for AWS resources, including an instance named "clumsy_bird" with associated costs. The interface indicates that the apply action will not run.

Key columns include:

  • Hourly Cost: Estimated rate per hour for each resource.
  • Monthly Cost: Projected charge over a full month.
  • Monthly Delta: Difference between the new monthly cost and the current state.

Resources without pricing data will appear as “cannot estimate cost.”

3. Testing Cost Impact

Modify your Terraform code to see how changes affect cost. For instance, update the EC2 instance type for the Clumsy Bird application from t2.micro to t2.small, commit your change, and run a new plan. The Cost Estimation section will highlight the updated delta:

The image shows a Terraform Cloud interface where an EC2 instance size upgrade is being applied. It includes details about the plan, cost estimation, and the application process, with a highlighted cost increase for an AWS instance named "clumsy_bird."

Upgrading from t2.micro to t2.small adds approximately $8.20 per month.

4. Supported Providers

Terraform Cloud Cost Estimation currently supports the following cloud providers:

ProviderCoverage
AWSEC2, RDS, S3, Lambda, and more
GCPCompute Engine, Cloud Storage, and more
AzureVirtual Machines, Storage Accounts, and more

Summary

Terraform Cloud’s Cost Estimation feature empowers teams to monitor and forecast infrastructure expenses before deployment. Enable it in your organization to incorporate cost visibility into your CI/CD workflows.

Watch Video

Watch video content

Practice Lab

Practice lab

Previous
Lab Solution Terraform Cloud Sentinel Policy