Cloud Cost Optimization with HashiCorp Terraform

Cloud is a driving force that is reshaping organizations to adapt their people and processes in embracing this game-changing technology. Recently, Mike Fonseca of HashiCorp published a Guide to Cloud Cost Optimization with HashiCorp Terraform, in which he details how Densify can seamlessly integrate with Terraform in to help ensure your enterprise infrastructure is always cost optimized.

Cloud Cost Optimization & the Emergence of FinOps

Why is infrastructure cost optimization so relevant today? The variable consumption nature of cloud has transformed the way Finance and Engineering function, demanding a tighter collaboration. With the advent of cloud, Finance continues to control infrastructure spend and Engineering manages cloud infrastructure technology procurement decisions—but now in real time and on demand.

Finance lacks control in the two primary areas of cost-saving:

Limited governance and control in the resource provisioning phase.
Limited governance and control in enforcing infrastructure changes for cost savings.

The push and pull of these responsibilities has left both departments scrambling to keep up with and enable elasticity and agility, and as a result of the fluctuating costs of cloud operation, Finance is left struggling to control variable IaaS costs while Engineers fight to maximize access to cloud resources for business stakeholders.

This cross-departmental challenge has given rise to the FinOps practice, which is transforming the way Finance and Engineering teams interact and collaborate. No longer operating in silos, FinOps demands these teams join to form a Cloud Center of Excellence—a collaboration across cross-functional teams in an enterprise to ensure delivery of a successful cloud operating model while executing on the organization’s cloud strategy. This team defines best practices, standards, security, governance, and of course, cost control measurements. In the HashiCorp paradigm, this team will help organizations execute on three stages of cloud.

HashiCorp’s Stages of Cloud Operation – Planning, Optimization, & Governance

In their guide, HashiCorp describes a three-stage FinOps lifecycle for running in the cloud:

Preparation for migration to cloud and ongoing cost forecasting
Operationalizing and realizing continuous cost savings
Ensuring future cost prudence and savings
Terraform cloud cost optimization management lifecycle
Densify technology is the foundation of the Optimization stage

For Finance and Engineering, working together means developing a cost conservation mindset. Every major cloud provider offers resources (their services) across a wide range of types and with a diverse set of features in order to cater to every possible business niche. Unfortunately, because of the innate complexity of these offerings, developers and engineers are not always able to select the best resource type for a given workload. Throwing greater capacity at a cloud workload is often not the answer. Selecting a bigger instance resource means paying more. Thus, being aware of workload utilization becomes central to selecting rightsized features.

HashiCorp & Densify

HashiCorp advises that enterprises manage cloud computing resources using analytics provided by optimization insight tools like Densify. Analysis of historical utilization data identifies usage trend and enables matching of each workload to the appropriate compute instance type. To further streamline this process, HashiCorp advises automation of this resourcing process through Terraform:

In any of these cases, especially if automation is taking place, it will be important to maintain key pieces of resource data as variables. The optimization insight tools will provide a size recommendation for resources or services (i.e. compute, DB, storage, etc.).


Visit the Densify Terraform Registry to access a series of modules that allow you to plug the deepest cloud analytics directly into your existing Terraform workflow. You can utilize Densify APIs to consume cloud optimization recommendations and store them in your code repository. As you deploy your infrastructure (depending on the frequency of your build cycles), invoke the Terraform lookup function to fetch these recommendations and optimize your infrastructure.

This seamless integration ensures that cloud cost optimization recommendations are part of your CI/CD pipeline and you are always operating at the lowest possible cost.

Learn even more by requesting a free cloud optimization trial or reaching out for a solution demonstration. Our dedicated cloud solution experts will be happy to have a conversation with you and assess your optimization opportunity.

Start Optimizing Your Cloud & Container Costs