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
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Infrastructure as Code: How Automation Evolved to Power AI Workloads
  • Theia Deep Dive, Part 2: Mastering Customization
  • Theia Deep Dive, Part 1: From Zero to Your Own IDE
  • Policy-as-Code for Terraform in Regulated Environments

Trending

  • Architecting an Embedded Efficiency Layer: A Platform Deep Dive into Day-Two Operational Tuning
  • Designing API-First EMR Architectures in .NET: Enabling Modular Growth in Compliance-Driven Systems
  • LLM Agents and Getting Started with Them
  • Docker Hardened Images Are Free Now — Here's What You Still Need to Build
  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.7K 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. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Infrastructure as Code: How Automation Evolved to Power AI Workloads
  • Theia Deep Dive, Part 2: Mastering Customization
  • Theia Deep Dive, Part 1: From Zero to Your Own IDE
  • Policy-as-Code for Terraform in Regulated Environments

Partner Resources

×

Comments

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

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook