TrademarkTrademark
Features
Documentation

Terraform Cost Estimation in 2021: The Definitive Guide

Learn more about Infracost, Scalr and Terraform Cloud providers
Ryan FeeJune 1, 2021
Terraform Cost Estimation in 2021: The Definitive Guide
Key takeaways
  • Terraform cost estimators calculate deployment cost by calling the cloud provider's pricing APIs from your templates and can display results in pull request comments, CLI output, or policy frameworks.
  • This 2021 comparison covers three providers for AWS: Infracost, Scalr, and Terraform Cloud; an editor's note flags that Scalr has since moved to run-based pricing and Terraform Cloud to a resources-under-management model.
  • Infracost is free and open source, installed as a binary or in CI/CD, and had the best AWS resource coverage, while Scalr and Terraform Cloud bundle cost estimation into their remote operations backends.
  • In an accuracy test on three AWS resources, Infracost and Scalr matched the AWS reference price exactly while Terraform Cloud slightly underestimated each.
  • For policy-as-code, Infracost has no integration, Scalr integrates natively with Open Policy Agent, and Terraform Cloud integrates with Sentinel.

Editor's note (2026): This 2021 comparison reflects Scalr's and Terraform Cloud's pricing at the time. Both have since changed — Scalr now uses run-based pricing (you pay per run, not per user, and the first 50 runs/month are free), and Terraform Cloud moved to a resources-under-management (RUM) model. The figures below are kept for historical context; see Scalr's current pricing for today's model.

According to DevOps.com, $6.6 billion were wasted on oversized cloud resources in 2020. The inability to quickly visualize the cost of deployment and the lack of guardrail implementation within organizations are some of the reasons why.

For teams that moved to infrastructure as code, and Terraform in particular, a few tools help head off that kind of waste. Terraform cost estimators calculate the cost of a deployment by calling the cloud provider's pricing APIs based on the Terraform templates they receive as input. The output is a breakdown of resource cost and how it changes compared to the current state. You can show it in pull request comments or CLI output, or feed it into a policy framework like Open Policy Agent or Sentinel.

In this article, we review the three main providers of cost estimation for Terraform: Infracost, Scalr and Terraform Cloud. We limited the scope of this guide to AWS, but these tools also have support for Google (Infracost, Scalr, Terraform Cloud) and Azure (Terraform Cloud). Please refer to their respective documentation (Infracost, Scalr, Terraform Cloud) to get an exhaustive view of the resources they support.

The goal is to help you decide which of these three providers fits your use case. We'll look at the setup process, the pricing, the resource coverage, the accuracy of the estimates, and how each one integrates with policy-as-code frameworks.

Summary

Infracost Scalr Terraform Cloud
Pricing (as of 2021) Free Free up to 5 users, $20/user/month starting 6 users (Scalr is now per-run) $70/user/month
Installation Binary Integrated Integrated
Policy As Code Framework Integration None Open Policy Agent Sentinel

Set up

Infracost

Infracost is free and open source. It must either be installed on your local machine (which is great for getting started or testing) or integrated into your CI/CD pipeline through GitHub Actions or Jenkins for example.

Install Infracost

Scalr & Terraform Cloud

Scalr and Terraform Cloud differ from Infracost because they are not just cost estimation tools, but rather remote state & operations backends that offer a cost estimation feature. Scalr and Terraform Cloud provide features around automation and collaboration on Terraform. To estimate Terraform costs with Scalr & Terraform Cloud, you'll first need to estimate the number of runs you need and then go to the Scalr sign-up page to see your cost estimates.

Create a free Terraform Cloud account

User Experience

Infracost

To run Infracost, just type the infracost command in the Terraform root directory. Infracost displays a detailed estimation of the monthly costs, broken down by resource. It also can post the results of the cost estimation to a pull request comment, where you'll be able to visualize the evolution of the cost based on the current state.

Infracost CLI output showing detailed monthly cost estimation broken down by resource

Infracost pull request comment showing cost evolution compared to current state

Scalr

Scalr automatically runs cost estimation during the plan and apply phases. It displays an estimation of the monthly costs as well as the evolution of the cost based on the previous state in the Scalr UI (for all runs) and in the CLI (for CLI-triggered runs).

Scalr UI displaying monthly cost estimation during Terraform plan and apply phases

Terraform Cloud

Like Scalr, Terraform Cloud displays an estimation of the monthly costs as well as the evolution of the cost based on the previous state on the UI and the CLI.

Terraform Cloud UI displaying monthly cost estimation and evolution from previous state

Price accuracy

We ran a quick experiment to see how accurate the cost estimations were compared to the AWS reference price on three resources that all providers support. Both Infracost and Scalr predicted the same and correct cost, while Terraform Cloud always slightly underestimated it.

us-west-2 AWS Reference Infracost Scalr Terraform Cloud
aws_db_instance 20 Go MySQL db.t2.micro $14.71 $14.71 $14.71 $14.46
aws_instance ubuntu t3.micro $8.39 $8.39 $8.39 $7.48
aws_ebs_volume 40 Go $4 $4 $4 $3.87

Policy As Code Integration

Letting developers see the cost of a deployment in the CLI or a pull request before running terraform apply is useful on its own. But you can go further: set guardrails that block a deployment automatically when it goes over a cost threshold. That's the job policy-as-code frameworks do.

Infracost has no integration with a policy as code framework, so you'll have to wire things up yourself to automatically enforce policy. Scalr integrates natively with Open Policy Agent, which is an open-source policy framework that works across the cloud-native stack. Here is an example of an OPA policy that checks if a cost estimate is above a certain threshold. Terraform Cloud integrates with Sentinel, Hashicorp's proprietary policy framework.

Infracost Scalr Terraform Cloud
No Open Policy Agent Sentinel

Conclusion

Infracost is a good place to start experimenting, especially if you already run a DIY Terraform pipeline and have no plan to move it to a remote state & operations backend. It had the best coverage for AWS resources, and it can comment on pull requests with the estimation results.

Scalr and Terraform Cloud work differently: cost estimation comes bundled into their remote operations backend, so you have to adopt them as your remote backend to use it. That can make sense if you're trying to standardize how your team uses Terraform and collaborate on it. The two mainly differ on pricing (at the time of writing, $20/user/month for Scalr if your team is larger than 6 vs. $70/user/month for Terraform Cloud; Scalr has since moved to run-based pricing and Terraform Cloud to a RUM model) and on the policy-as-code framework they support (Open Policy Agent for Scalr, Hashicorp's Sentinel for Terraform Cloud).

Either way, Terraform cost estimation is still a young area, and 2021 will probably bring a lot of improvement in the resources and cloud providers these tools support.

About the author
Ryan Feedirector of platform engineering at Scalr
Ryan Fee is the director of platform engineering at Scalr, with over 15 years of experience improving infrastructure experiences at companies large and small.