Introduction to Terraform

Terraform Jan 10, 2023

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 main uses of Terraform is to provision resources within your datacenter, 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 great use case for Terraform is the ability to create custom providers.  As we mentioned before, a Terraform provider is a wrapper around an existing API. Engineers can create providers for their companies use cases.

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

Is Terraform a tool or language?

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

Do we need coding experience for Terraform?

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

Terraform can be used by anyone within the IT industry.

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

How to install Terraform on Windows

In order 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 the management of 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 over 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 the format of a ZIP file.  

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.

The next step is to start creating Terraform deployments, enjoy!

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.