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

  • Terraform Drift Detection at Scale: How to Catch Configuration Drift Early
  • Understanding Infrastructure as Code at Scale
  • Understanding the Purposes of Key Terraform Files and How to Structure Their Folders
  • Terraform Tips for Efficient Infrastructure Management

Trending

  • Monolith: The Good, The Bad and The Ugly
  • How to Create a Successful API Ecosystem
  • Event-Driven Microservices: How Kafka and RabbitMQ Power Scalable Systems
  • How To Introduce a New API Quickly Using Quarkus and ChatGPT
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Must-Have Infrastructure as Code Tools

Must-Have Infrastructure as Code Tools

A small set of tools to make your Terraform coding journey smoother. Tools to Lint, visualize, document, and clean your Terraform HCL2 code.

By 
Vidyasagar (Sarath Chandra) Machupalli FBCS user avatar
Vidyasagar (Sarath Chandra) Machupalli FBCS
DZone Core CORE ·
Jul. 03, 23 · Opinion
Likes (4)
Comment
Save
Tweet
Share
4.3K Views

Join the DZone community and get the full member experience.

Join For Free

Here are some handy tools that made my Terraform coding journey smoother and should help your Terraform coding as well.

What Is Terraform?

For starters, Terraform is an infrastructure as a code (IaC) tool that helps you provision Cloud or On-premise resources through declarative configuration. Terraform uses HCL2 (Hashicorp Configuration Language).

HCL2 = HCL1 + HIL (Hashicorp Interpolation Language)

Check this GitHub repository to learn more about HIL.

Use Different Terraform Versions

If you are familiar with the Node.js world, different projects require different versions. So, I use nvm(node version manager). Similarly, in our Terraform world, there are tfswitch and tfenv to use different versions of Terraform for different projects or for testing your Terraform project with different versions of Terraform.

  • TFSwitch
  • tfenv

tfswitch showing Terraform versions

Visualize Terraform

It helps to visualize your Terraform resources, modules, etc., to understand the flow and the connections.

I published an article that talks about various visualization tools associated with Terraform. It includes the inbuilt terraform graph. 

Code Formatting, Code Navigation, Syntax Highlighting

You can always run Terraform commands to format and validate your HCL2 code like this: 

terraform fmt
terraform validate


Running these commands on a project with a complex folder structure becomes tiresome, as there can be multiple directories with *.tf files.

  1. Visual Studio Code Extension to the rescue.

Visual Studio Code Extension

Hashicorp Terraform extension for Visual Studio Code

2. Language Server

Terraform Language server is the official language server created and maintained by the creators of Terraform that provides IDE support.

Add support for the Terraform configuration language to editors that use the Language Server Protocol, like Sublime Text, vim, emacs, etc.
- Hashicorp

3. Terraform by Anton

This is a Visual Studio Code extension. Adds syntax support for the Terraform and Terragrunt configuration language.

Documentation

Terraform-docs generates documentation for Terraform modules in multiple formats. The tool lists modules, resources, inputs, outputs, providers, data resources, etc., The tool provides --recursive flag to update submodules recursively.

Sample commands showing the markdown format

terraform-docs markdown . >>README.md
terraform-docs markdown table .


Check a sample markdown file generated using Terraform-docs. The Terraform is associated with this article.

As developers, we have a habit of forgetting things. Cleaning the code is one of the most important thing that we always forget. Terraform cleaner to the rescue.

Terraform Cleaner

Terraform Cleaner is a tool to detect Unused Variables and Locals in Your Modules. You can find the complete documentation in the article "Terraform Cleaner — A Tool to Detect Unused Variables and Locals in Your Modules."

Additional Tools

Heard about terraform console command? How many times as developers would we have thought of evaluating a list of objects or any other expression without running terraform plan or terraform apply commands? The terraform console command helps you to evaluate and experiment with expressions on a terminal or command prompt. You can experiment with built-in terraform functions like slice, split, cat, etc., even before incorporating them into your HCL2 code.

Additionally, you can check other tools for security and compliance, validation, automation, etc., on the official Hashicorp documentation.

Also available are tools from the awesome-terraform GitHub repository.

Integrated development environment Visual Studio Code Terraform (software) Infrastructure as code

Published at DZone with permission of Vidyasagar (Sarath Chandra) Machupalli FBCS, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Terraform Drift Detection at Scale: How to Catch Configuration Drift Early
  • Understanding Infrastructure as Code at Scale
  • Understanding the Purposes of Key Terraform Files and How to Structure Their Folders
  • Terraform Tips for Efficient Infrastructure Management

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!