Skip to content

Becomming Terraform certified

Published: at 18:12

Last week I got my Terraform Associate (003) certification. After having worked with Terraform for about a month and a half now, I felt challenged to obtain this certification.

All in all it took me about four evenings (about 8 hours, Who studies longer than 2 hours after a full workday?šŸ˜œ) of real studying to get the certification. ofcourse I already had some practical experience with Terraform when using it in my day job, but I still had to learn a lot of the theory behind it and about Terraform Cloud, which is a pretty big part of the exam.

For me, this was the first type of studying and exam I did after graduating university last summer. Before we dive into the specifics of the exam and me giving you some free tips for learning Terraform, let me first explain what Terraform is.

What is Terraform?

Terraform is an open-source tool that allows you to manage and provision your IT infrastructure using code, a concept known as ā€˜Infrastructure as Codeā€™ (IaC). Instead of manually setting up servers, databases, and other IT resources, you write a script in Terraformā€™s language, and it does the setup for you.

The benefit of using Terraform is that itā€™s platform-independent, which means you can use it with many different cloud providers such as AWS, Google Cloud, Azure, and others. Terraform uses text files, known as ā€˜Terraform configuration filesā€™, to define the resources you want to create. This allows you to track changes, share configurations, and automate your infrastructure, making it faster, more efficient, and less prone to human error.

Core concepts

In order to understand Terraform correctly there are a few core concepts you first need to understand before you start working with the tool.

HCL

Short for HashiCorp Configuration Language, HCL is the language that you use to write your scripts in Terraform. Itā€™s designed to be easy to read and write, with a clear and intuitive syntax. HCL allows you to define and provide data to your infrastructure resources, such as servers or databases. Itā€™s also flexible, enabling you to use variables, perform operations, and organize your configurations into modules, making them more manageable and reusable.

An example snippet of HCL that creates an Ubuntu based virtual machine on Microsoft Azure.

resource "azurerm_linux_virtual_machine" "example" {
  name                = "example-vm"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  size                = "Standard_F2"
  admin_username      = "adminuser"
  network_interface_id = azurerm_network_interface.example.id

  admin_ssh_key {
    username   = "adminuser"
    public_key = file("~/.ssh/id_rsa.pub")
  }

  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  source_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "16.04-LTS"
    version   = "latest"
  }
}

Providers

In Terraform, a provider is a plugin that interacts with a specific serviceā€™s API, such as AWS, Google Cloud, or Azure. Providers are what give Terraform its ability to manage such a wide variety of services. Each provider offers resources that you can manage, like a virtual machine in Azure or an S3 bucket in AWS. When you write your Terraform scripts, you specify which provider(s) you want to use, and then you can use the resources that those providers offer.

State

The state in Terraform is a crucial concept. Itā€™s a JSON file that records the current settings and data of your managed infrastructure. The state file maps your Terraform scripts to the real resources they manage, allowing Terraform to know what it has set up previously and what needs to be changed if you adjust your scripts. The state also stores configuration data that your resources might need. Itā€™s important to manage this state file carefully, especially in a team setting, because it is key to how Terraform operates and maintains consistency in your infrastructure.

Sounds cool, I want to start using Terraform

If you want to start using Terraform I would really recommend following one of the multiple tutorials they have outlined on their website. You can choose a tutorial using any major cloud provider, or start for free provisioning local infrastrucutre using Docker. Another tip I would give is to just start.

When using the tutorial for one of the big cloud providers you do need to have an account with a billable creditcard. You can follow the tutorial without making any costs since they all use resources which are provided in the free tiers. If thats to much of an hassle for you, just use the tutorial where you will be creating local resources using DockeršŸ³.

Getting Terraform Certified

Studying for the exam

This certification is not the type where you would need years of experience in order to obtain it.To prepare for the Terraform Associate exam, you can use both a study guide and a review guide provided by HashiCorp. These guides will help you understand all the exam objectives. If you already have experience with Terraform, the review guide will help you choose which objectives to review before taking the exam. HashiCorp also provides sample questions to give you a feel for what the exam will be like.

The exam tests your understanding of a variety of Terraform concepts and skills:

  1. Understanding infrastructure as code (IaC) concepts
  2. Understanding the purpose of Terraform (vs other IaC)
  3. Understanding Terraform basics (i.e., commands, operators, etc.)
  4. Using Terraform outside of core workflow (commands like import, taint, etc.)
  5. Interacting with Terraform modules
  6. Using the core Terraform workflow (commands like init, plan, apply, etc.)
  7. Implementing and maintaining state (using remote backends, state locking, etc.)
  8. Reading, generating, and modifying configuration

For a detailed description of these objectives, check out the official HashiCorp exam objectives page.

Exam details

The exam is online and proctored, taking approximately 1 hour to complete. It is comprised of multiple-choice questions and costs about $70.00 USD plus locally applicable taxes and fees. Note that a free retake is not included in this cost. The certification is valid for 2 years, after which you will need to retake the exam to maintain your certification.

You take the exam in an online portal, during the exam you need to have your webcam on and you are not allowed to leave the room. The exam is 60 minutes and consists of 55 questions. You need to score 70% or higher in order to pass the exam.

Cheat sheet

During my preparation for the exam I used a cheat sheet with all the commands and concepts I needed to know for the exam. You can find the cheat sheet here.