Introduction to Terraform

In this article we look at what Terraform is, what Terraform is used for, and how to install Terraform on Windows.

Introduction to Terraform
Introduction to Terraform

Infrastructure as Code (IaC) allows you to programmatically provision the infrastructure you need to run your software code or resources for your organisation. There are many tools considered as IaC tools. Hashicorp’s Terraform is one such Infrastructure as Code tool.

Terraform is an open-source DevOps tool that uses Hashicorp Configuration Language (HCL) to define and provision your infrastructure. It can be used with AWS, Azure, Google Cloud and your on-premises infrastructure.

What is Terraform used for?

One of the primary uses of Terraform is to provision resources within your data center, whether that is on-premises or in the cloud.

Terraform can help you provision resources through what is called a provider. A Terraform provider can be thought of like a plugin that wraps an existing API to create declarative Terraform syntax.

The providers are open-source and closely monitored by Hashicorp (the company behind Terraform). The providers receive regular updates.

Terraform is also popular and used by many engineers to perform multi-cloud deployments.

Terraform can be used to provision resources to a lot of different cloud providers, this means that engineers don’t have to learn multiple tools and language syntax. They can re-use their knowledge to help create templates to deploy to any cloud provider.

Another excellent use case for Terraform is the ability to create custom providers. As mentioned, a Terraform provider is a wrapper around an existing API. Engineers can develop providers for their company's use cases.

Any API that supports Create, Read, Update, Delete (CRUD) actions can be wrapped into a Terraform provider, giving Terraform much flexibility.

Is Terraform a tool or language?

Terraform is an open-source tool written in the Go programming language.

💡
You might be interested in my book "Terraform for Ops", a guide to Terraform for SysAdmins. You can find out more information here https://www.terraformforops.com

Do we need coding experience for Terraform?

Terraform is an easy tool to get started with. There is a lot of great getting-started guides. But ultimately, no, you do not need to be a coder or developer to use Terraform.

Terraform can be used by anyone within the IT industry.

Having a basic understanding of how code works and how to format it and troubleshoot can be advantageous but unnecessary. If you are using Visual Studio Code (VSCode) and the Terraform extension, it will help with syntax highlighting, IntelliSense, code navigation, and code formatting, which can be helpful even for the most experienced engineer.

How to install Terraform on Windows

To use Terraform, you do have to install it on your machine. I want to show you two ways of doing this.

The first is using the package manager, Chocolatey. If you aren’t already using Chocolatey, I encourage you to check it out and see how it can assist you with managing software on your machine.

To install Terraform using Chocolatey, you can open up a command line tool and type in:

choco install terraform -y
Install Terraform with Chocolatey
Install Terraform with Chocolatey

Alternatively, you can head to https://developer.hashicorp.com/terraform/downloads, select Windows as the operating system and download the relevant binary.

Once the file has been downloaded, it will be in a ZIP file format.

Extract this file to a directory of your choosing (for example, c:\terraform).

Next, navigate to Control Panel -> System -> Advanced System settings

Windows 11 Control Panel
Windows 11 Control Panel

Now select Environment Variables

Windows 11 System Properties
Windows 11 System Properties

Double-click on PATH

Click New and add in the path you extracted the Terraform application to

Windows 11 Environment Variables
Windows 11 Environment Variables

Click OK twice.

Launch a new command line prompt and type in “Terraform -version”

It should respond with the version you have just installed.

Terraform in 10 minutes

Check out my video where I give an overview of Terraform in 10 minutes.