DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Infrastructure as Code (IaC) Tools, Part 1: Overview of Tools
  • Optimizing Integration Workflows With Spark Structured Streaming and Cloud Services
  • Codify Your Cloud and Kubernetes With Crossplane and IaC
  • Streamlining HashiCorp Cloud Platform (HCP) Deployments With Terraform

Trending

  • System Coexistence: Bridging Legacy and Modern Architecture
  • How to Convert XLS to XLSX in Java
  • After 9 Years, Microsoft Fulfills This Windows Feature Request
  • Introduction to Retrieval Augmented Generation (RAG)
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. How To Integrate Infracost With Terraform Cloud

How To Integrate Infracost With Terraform Cloud

Infracost is a verified Terraform Cloud integration. Learn everything you need to know regarding how to integrate this tool with Terraform to deploy a hybrid cloud environment.

By 
Florian Pialoux user avatar
Florian Pialoux
·
Jan. 31, 22 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
3.9K Views

Join the DZone community and get the full member experience.

Join For Free

Running infrastructure at any scale almost always guarantees a dizzying array of components and configurations. To further complicate things, different teams within an organization may need similar infrastructures with slight variations. Additionally, that infrastructure may be spread over multiple topographies, from on-premise to one or more cloud vendors.

Terraform is Hashicorp’s service offering that can provision infrastructure across multiple clouds and on-premises data centers, in addition to safely and efficiently re-provisioning infrastructure in response to configuration changes. 

This article explores why you need to know about Terraform Cloud if your organization plans to deploy a hybrid cloud or multi-cloud environment. We also outline how you can integrate Terraform Cloud with Infracost. 

Table of Contents

  • What is Terraform Cloud?
  • Why Terraform Cloud?
  • Infracost and Terraform
  • How to Integrate Infracost with Terraform
  • Conclusion

What Is Terraform Cloud?

Terraform is an open-source “Infrastructure as Code”(IaC) tool created by HashiCorp.

Terraform enables developers to use a high-level configuration language called HCL (HashiCorp Configuration Language) to describe the desired “end-state” cloud or on-premises infrastructure for running an application.

Essentially, Terraform Cloud is a great and easy way to apply your Terraform Code. In terms of pricing, different tier plans exist, but the free tier can still satisfy most of your needs. One of the reasons why Terraform cloud is popular right now is because there's no need to find a remote host to store your state file.  Instead, Terraform Cloud will directly manage, host, and encrypt it at rest with versioning enabled by default.

At any point, you can access older states, view and restore them. The entire security applied around this is done by HashiCorp, reducing any administration overhead you might encounter if you were managing the state file yourself. A plan or application can be triggered simply with a Git commit to your repository, where your IaC resides. It supports most of the Version Control repository management, including the self-hosted ones.

Learn more about how this works here. 

Why Terraform Cloud? 

Terraform Cloud eliminates the need for unnecessary tooling and documentation to use Terraform in production. To better understand Terraform’s benefits, it is vital to first learn about the advantage of Infrastructure as Code (IaC). Primarily, IaC enables developers to codify infrastructure in a way that allows provisioning to be not only automated but also faster and repeatable. Note that IaC is a key part of Agile and DevOps practices such as; 

  • Version control
  • Continuous integration
  • Continuous deployment

With this in mind, the reasons why developers are drifting towards Terraform include its: 

  • Immutable infrastructure
  • Support for multiple platforms
  • Open-source nature
  • Scalability

Infracost and Terraform Cloud

Infracost is an open-source project released in June 2020. Infracost aims to help companies estimate the cost of every IaC change made to their cloud infrastructure. 

With that in mind, previously, to integrate Infracost into your CI/CD pipeline, you needed to rely on your Version Control repository management e.g 

  • GitLab
  • GitHub
  • Bitbucket

This was made possible based on the fact that Infracost already has integrations with these tools. All you need to do is make a pull request, after which Infracost will compare the previous state with the planned state and then comment on the difference in your pull request.

You may be wondering, what if you are using Terraform Cloud? Is there an easier way to integrate Infracost into it? Well, Run Tasks is a new feature (still in beta at the time of writing) for Terraform Cloud and is likely to become available to the public by the end of the year.

This feature allows you to integrate third-party tools such as BridgeCrew, Snyk, Refactr, CloudTamer, and Infracost between the plan and apply stage. If you're hoping to develop your own integration, HashiCorp, Terraform’s parent company,  built some documentation on how to achieve this. You can also find more information about Run Task here.

How To Integrate Infracost to Terraform Cloud

Using the run task feature explained above, integrating Infracost with Terraform Cloud is pretty straightforward.

All you have to do is:

  1. Grab your unique Infracost hook endpoint URL and HMAC Key by registering at the following form. 
  2. Navigate to “Task event hooks” in your organization setting and fill up the blank fields with the information generated in step 1; if you aren't sure where to find this setting, see the screenshot below or this link.
  3. The final step is to enable the task on your workspace, as shown in the screenshot below. 
  4. Voilà! Now, whenever Terraform Cloud runs a plan, you will see a new stage called for this run task with Infracost similar to the one we enabled for our test:

If you click on details, this is where we see something new; a unique URL generated for you by Infracost. This is a fantastic feature as it can be shared with the rest of your team and offers a rundown on the cost difference.

Conclusion

Terraform’s “Run Tasks,” which is in the beta phase, enables your organization to integrate third-party tools such as Infracost within a Terraform run. Specifically, its utility comes in handy between the plan and apply stages of the Terraform Cloud workflow. Essentially, anything from security checks to cost estimation to code scanning can be integrated into your Terraform workflow with the Run Tasks feature. We hope this feature will become quickly available for everyone as it can unlock lots of exciting possibilities.

Terraform (software) Cloud Integration

Published at DZone with permission of Florian Pialoux. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Infrastructure as Code (IaC) Tools, Part 1: Overview of Tools
  • Optimizing Integration Workflows With Spark Structured Streaming and Cloud Services
  • Codify Your Cloud and Kubernetes With Crossplane and IaC
  • Streamlining HashiCorp Cloud Platform (HCP) Deployments With Terraform

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!