What is Terraform and why you need to know it
- Emanuel Burgess
- Mar 11, 2023
- 3 min read
Getting started in the cloud can be pretty intimidating. There is so much to learn and sometimes it’s hard to know what to learn. If you plan on touching any component of operations then Terraform is essential. What do we mean when we say operations? An operations team is responsible for the ongoing management and maintenance of a company's IT infrastructure and systems. Some job titles that could have some overlapping operations responsibilities would be DevOps, DevSecOps, or cloud engineer just to name a few. Terraform is an infrastructure as code (IAC) tool that allows you to define and manage your infrastructure as code developed by HashiCorp. It is open-source and can be used for free (Hashicorp also offers a paid version). Terraform can be used to create, modify, and destroy resources across multiple cloud providers and on-prem.
What is infrastructure

Let’s talk about infrastructure. What is it? Infrastructure can be defined as any software element you want to build in the cloud. In reference to AWS, this could be a virtual machine like an ec2 or storage like an S3 bucket, basically anything that you can build via the cloud console.
How Terraform works
In its simplest form, Terraform from a high-level implementation standpoint looks like nothing more than a bunch of text or configuration files that get translated into API calls which in turn are used to build whatever you specify in those text files. But looking closer you see Terraform uses a configuration language to describe infrastructure. That language is called HCL (HashiCorp Configuration Language). HCL is declarative in nature meaning when you write code within Terraform it describes the desired outcome instead of writing step-by-step instructions Terraform should follow to reach a specific outcome.
It’s a Block party!

With Terraform you create a resource with a block. These blocks are called “resource blocks”. A resource block corresponds to a resource in AWS. For example, if I wanted to build an EC2 in AWS I would use an aws_instance resource block. If I wanted to create an S3 bucket you would use the aws_s3_bucket resource block.
Ok great so you know how to build a resource, but how do you configure it? Terraform uses a concept called arguments. An argument is a key-value pair that is used to configure a resource or module. For example, if you wanted to create a dynamo DB table in Terraform you would need to give that table a name. You could also specify the read/write capacity as well as a hash key. Your terraform code could look something like this:
Provider blocks
A provider block is a configuration block that defines a provider. This provider contains a plugin that is needed in order for Terraform to interact with a particular cloud platform or service. Providers are responsible for translating Terraform configuration into API requests. Meaning whenever you run a command like Terraform apply on the backend Terraform is making API calls to AWS in order to build your resources.

In the example above we are using an “aws” provider. This tells Terraform we want to build resources in AWS so whenever we initialize our directory using Terraform init all of the plugins needed for this specific version of the AWS provider will be downloaded.
Why you should learn Terraform
Terraform is a powerful tool that can manage complex infrastructure. Some additional benefits to Terraform are:
Cloud agnostic: Terraform supports multiple clouds like AWS, Azure, Google Cloud, and the list goes on. This means that you can use the same tool to build infrastructure across different cloud providers without having to learn new code.
Infrastructure as Code (IaC): Terraform is a tool used for Infrastructure as Code (IaC) which allows you to describe your data center or resources in text files. This makes it easier to manage and maintain your infrastructure.
Version Control: Terraform code can be stored in version control systems like Git and sent to source code repositories like GitHub or Code Commit. This is powerful because now you can track changes over time and collaborate with others. This allows you to version control your infrastructure.
Modules: You can create modules in Terraform. Modules allow you to break down your infrastructure into smaller, reusable components. Modules are used to create reusable components. These components can be shared across different Terraform configurations.
Terraform is important because your software has to run on something right? Terraform enables you to automate your infrastructure management tasks and helps ensure consistency, reliability, and scalability.
Want to dive deeper into Terraform but videos aren’t enough? Check out www.cloudafterdark.com where we provide one-on-one hands-on training in real-time with a seasoned instructor. Get the mentorship and training you need today!
Comments