Introduction to Terraform
Tags: terraform, iac
Published: 2023-01-10 14:00:00

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](https://www.techielass.com/infrastructure-as-code-the-benefits-and-the-tools/).  Hashicorp’s [Terraform](https://www.terraform.io/) is one such Infrastructure as Code tool.  

Terraform is an open source [DevOps](https://www.techielass.com/tag/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](https://developer.hashicorp.com/terraform/tutorials).  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)](https://code.visualstudio.com/) and the [Terraform extension](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform) 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](https://www.techielass.com/chocolatey-what-is-it/).  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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fviejgmrlqzf0j81b5i1.png)

Alternatively you can head over to [https://developer.hashicorp.com/terraform/downloads](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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hcxwisu4kb1ezjk3x2ga.png)

Now select Environment Variables

![Windows 11 System Properties](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hz388p2i5217cyq6mmpn.png)

Double click on PATH

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

![Windows 11 Environment Variables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7us6w872gw2sqmww1fah.png)

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
I've created a video which covers off Terraform in 10minutes.  A great starter video if you are new to Terraform completely.

{% embed https://youtu.be/h6rkauDhDUM %}