How I passed the HashiCorp Terraform Certification

Du'An Lightfoot
8 min readApr 27, 2022

If you have been following my posts, you know I am learning everything that I can about cloud networking. The first goal was to learn about AWS.

This has helped me build foundational knowledge in cloud computing and the services AWS offers. It has also helped me to become more proficient in my current role as a Developer Advocate.

The next goal was to learn about automation and the tools used to build and manage infrastructure and resources in the cloud. Here are the current tools on my list: AWS Cloud Development Kit (CDK), AWS CloudFormation and HashiCorp’s Terraform.

Of the three I am most experienced with Terraform, so I decided to start there.

In this post, I plan to provide you with an overview of Infrastructure as Code (IaC) and Terraform. I will also discuss the Terraform certification to help you decide if it is right for you. We will close by providing resources to help you prepare for the HashiCorp Certified: Terraform Associate exam.

Before we begin, I want to thank everyone on LinkedIn and Twitter for taking the time to help me tailor this post. You all are awesome!! Big thanks!

What is Infrastructure as Code?

Infrastructure as Code (IaC) is exactly what the name implies. IaC is the managing and provisioning of infrastructure through code in a safe, consistent, and repeatable way instead of through manual processes. The code itself is stored either locally, in a remote version control system like GitHub, or a service like AWS Code Commit.

Why does Infrastructure as Code matter?

Humans by nature are error prone. When manually configuring infrastructure mistakes happen. When these mistakes occur, the creation of new environments are not always repeatable, reliable, or consistent. Leading to operational downtown, deployment roll backs, and other issues that can stop an organization from innovating.

What is Terraform?

Terraform is an open-source infrastructure as code software tool. It allows you to define and create resources in the cloud and on-prem. It does this by using providers which handle the API calls to cloud service providers like AWS. Terraform is also declarative in how it operates. Meaning that we only tell Terraform what we want it to do with no further directions needed. As opposed to being imperative and the developer also having to explicitly define each step to accomplish the desired task.

The real power of Terraform isn’t the fact that it can build infrastructure. Terraform stores the infrastructure’s state. It creates a state file named terraform.tfstate that can be stored locally or in a backend like Terraform Cloud or in an Amazon S3 bucket. By using a backend like Terraform Cloud you have the ability to lock the state for all operations that could write state.

Terraform with S3 and DynamoDB backend

The state file stores bindings between objects in a remote system and resources that are declared in your code. This enables you to manage the lifecycle of your infrastructure’s state. If any changes drift in your infrastructure that does not match your code, you will know.

Another benefit of Terraform is that you can scale or destroy resources as needed. Since your infrastructure is in code, scaling can be as simple as modifying a variable then running a terraform apply command to deploy more resources. And to destroy all resources in your configuration only requires executing terraform destroy. Keep in mind that Terraform is idempotent. This means that when you run Terraform if no changes are needed then no changes will be applied.

About the Terraform Associate Certification Exam

According to HashiCorp, the Terraform Associate certification is for Cloud Engineers specializing in operations, IT, or development. Those who know the basic concepts and skills associated with open source HashiCorp Terraform.

For me, I used this certification as a guide to learn more about IaC and Terraform. We will talk more about my experience in a moment.

How many questions are on the exam?

You will have 1 hour to complete 57–60 multiple-choice questions. The exam is delivered through PSI.

How much is the exam?

At the time of this post, the price of the exam is $70.50.

Does the HashiCorp Terraform Associate certification expire?

Yes. You are required to recertify every 2 years.

Are there any prerequisites?

You only need basic terminal skills. Along with a basic understanding of on premises and cloud architecture.

How long did it take me to prepare?

For the exam, it took me two weeks to prepare and pass. The first week was spent exploring Terraform’s documentation while attempting to write code. Cloud computing and infrastructure as code were not areas that I needed to focus on learning since I already had prior knowledge in those areas. Plus, in a previous position, I used Terraform to deploy resources to Cisco’s ACI. So, I did have some experience coming into the exam.

Example of using Terraform to manage a subnet resource in ACI

The next week I shifted to a more focused detailed learning plan. In total, I spent 30 hours preparing for this exam. The first 20 hours were spent in the terminal using Terraform to deploy, manage and destroy resources on AWS. For the remaining 10 hours I read documentation, watched training videos, and studied practice exams.

Even after passing the certification, I still have a lot to learn. This is not an expert-level exam by any means. In my opinion, this certification is a good primer to help you get started on your cloud automation journey.

Is this exam for you?

This is a great question and one that we will answer before we even talk about resources. My answer is that it depends.

Terraform is a hot tool that developers, architects, cloud engineers, and IT pros leverage throughout the industry. But that’s the thing, they are applying what they learn!

If you have no need for Terraform in your current role it may not benefit you to learn the skill. But if you are using Python or Ansible to automate workloads to the cloud or on prem to something like Cisco’s ACI, then adding Terraform to your skillset could makes sense.

What resources did I use to prepare for the exam?

- HashiCorp Certified: Terraform Associate Exam Topic –Start here to find the areas and topics that will be covered on the exam.

- Terraform Review Guide — This guide is helpful. It takes each example topic and provides links to documentation that you can use to prepare for the exam.

- Sample Exam Questions — Here are free sample questions that provide an insight into what the questions will look like on the exam.

- Terraform Language Documentation — This link provides the basics of the language. Get use to using the Terraform documentation.

- AWS Provider Documentation — The cloud that I used to prepare for the exam was AWS. This documentation has the information you need to start using the AWS provider.

- Create a free AWS account: — Here’s a link to create an AWS account. For this exam I recommend spending as much time as possible building, deploying, and destroying resources. AWS is also the cloud that is used in the courses I share below.

- Build a Dev Environment in Terraform — This is a free 2-hour video lab. The course walks you through getting started with Terraform.

- More than certified Terraform course — This course is the paid version of the course above. I think it was a good course. My only drawback is that the course focuses completely on doing rather than theory. But that’s also a great thing if you are looking to get something deployed fast.

- Hashicorp Certified: Terraform Associate Practice Exam 2022 (Udemy) — Practice exams are helpful when preparing for a certification. There are over 300 unique questions and 6 total practice tests.

Do you need to know how to code before learning Terraform?

To learn Terraform you do not need to know how to code. But I will say that learning Python prepared me for Terraform.

Python uses common programming constructs like loops, modules, and conditionals. This is also used in the HashiCorp Conguration Language (HCL). HCL is the declarative configuration language used to define resources in Terraform. Here’s an example:

Reference to the vpc module that will create VPCs

Knowing a programming language can help, but is not required.

There is one more thing you need to know. Terraform is used to orchestrate or deploy your resources. Once they are deployed you will still need to configure the resources. This ‘can’ be done in Terraform through a number of mechanisms. But this is not good practice (or a good idea unless necessary). That’s where Python and Ansible can become your configuration management tools to push out changes. An example is updating a webpage or updating network devices.

How hard was the exam?

If I had to rate the difficulty of the exam from 1 to 5. With 5 being the greatest difficulty, I rate the exam a 2. But realize this is relative and everyone will not rate it the same.

The reason why I rated it so low is because this exam solely focused on the fact of understanding how to use Terraform. It does not deviate from that. Unlike the AWS Solutions Architect certification where you have a vast number of services that can be covered on the exam.

How I passed the exam?

Every exam requires a strategy and this one is no different. To pass the exam you need to do one thing: #LabEveryday. You knew I would say that. But in all seriousness, for the exam let’s talk about what you need to know.

You have to understand how to write, plan, and create a Terraform workflow. Spend as much time as possible in the lab. Get comfortable writing Terraform code and running Terraform commands in the terminal. Things like dynamic blocks, local and remote backends, importing resources into your existing state, and how to taint a resource. These are items you need to know for the exam and when using Terraform in production.

As a bonus here are basic Terraform Commands:

The main Terraform commands:

terraform init — initializes a terraform working directory and installs backends, modules, and plugins.

terraform validate — Checks to ensure code is syntactically and internally consistent.

terraform plan — Takes your configuration and creates an execution plan. You then can verify what changes will be made before they are applied.

terraform apply — Create or update the infrastructure

terraform destroy — Destroy previously created infrastructure

Other Terraform commands to know:

terraform console — Enter into the Terraform console

terraform fmt — Reformats your configuration files in the standard format and style. (Cleans up your code)

terraform import — Used to import existing resources into the terraform state

terraform output — Shows output values from the root module

terraform state list — To list deployed resources

terraform show — View all of the resources in your infrastructure’s state

terraform taint — Used to mark a resource as not fully functional and will be replaced with the next terraform apply

terraform version — shows the current version of Terraform

terraform workspace — Manages Terraform workspaces

My final thoughts

Certifications are useful in providing a roadmap to learn new skills. Of course, they also improve your resume. But they are not the end game.

Although I am now certified, my cloud journey continues. Join me next month at the AWS Summit in Washington DC. Where I will be hosting a workshop titled: “Scale Your Cloud Network to Infinity and Beyond.” It will be an exciting session on scaling your Amazon VPCs, Transits Gateways with Terraform. Hope to see you there!

If you found this post helpful, please like, comment and follow me for more cloud networking related content. I wish you much success on your Terraform certification!

Peace,

--

--

Du'An Lightfoot

Everyday I strive to learn something new. Cloud Networking Developer Advocate @ AWS. Posts are my own opinions. #LabEveryday https://twitter.com/labeveryday