Terraform Interview Questions [with example answers]

29 Terraform interview questions and example answers to help you land your next job

terraform interview questions

If you want to land a job working with Terraform, it’s important to prepare for all the most common Terraform interview questions. While experience with other IaC tools is an asset, any employer hiring for a Terraform position is sure to ask Terraform-specific questions. Before your interview, make sure to prepare for answers for Terraform questions like:

  • What is IaC?
  • What is a Terraform Provisioner?
  • What is State Locking?
  • What is a Resource Graph?

And more.

In this article, we will provide a list of the most common Terraform interview questions and strong example answers, so you will be ready to ace your interview in no time.

What is Terraform?

Terraform is an Infrastructure as Code tool, or IaC, that enables DevOps teams to manage and maintain infrastructure using configuration files. Terraform is open-source, and is developed by HashiCorp, a software company from San Francisco. It supports multiple cloud platforms simultaneously, allowing large teams to collaborate without requiring multiple IaC tools.

Terraform Interview Questions

To get ready to interview for a Terraform position, you need to prepare for all of the most common Terraform interview questions. Terraform interview questions include:

1. What is IaC?

IaC stands for Infrastructure as Code. It refers to the practice of managing the infrastructure of an application using programming. It allows IT teams to control resources without having to manually configure each individual resource. It does not require a graphical user interface (GUI).

2. What is Terraform?

Terraform is an open-source Infrastructure as Code tool developed by HashiCorp. Terraform allows you to manage an application’s lifecycle by defining its resources using human-readable Configuration files. It supports most cloud environments, enabling DevOps teams to provision resources across multiple data centres.

3. Why would you choose Terraform for your DevOps team?

Terraform is an efficient and scalable way to build, update, and version application resources and infrastructure. It uses human-readable language and supports multiple cloud environments simultaneously. This means that large teams can collaborate seamlessly without needing to learn multiple IaC tools. It also has a large community and a stable, open-source code base, so many developers are already familiar with it and support is easy to find.

4. How does Terraform work?

Terraform works using a human-readable language called HashiCorp Configuration Language, or HCL, to define and manage infrastructure for an application. It uses configuration files to allow DevOps teams to programmatically manage resources and infrastructure. It is open source, and uses plugins from the DevOps community to support different features. Terraform supports most popular cloud environments, including AWS and Azure.

5. What is “Terraform init”?

“Terraform init” is the Terraform command that initializes the code in the current directory. It can be used to install plugins, modules, and more.

6. What technologies does Terraform support?

Terraform is cloud-agnostic. This means it can support nearly any cloud technology. Popular cloud technologies that Terraform supports include:

  • Amazon Web Services
  • Google Cloud Platform
  • Heroku
  • IBM Cloud
  • OpenStack
  • VMware vSphere
  • DigitalOcean

Terraform also supports different version control tools, such as:

  • Microsoft Azure
  • Bitbucket Cloud
  • Gitlab EE
  • Gitlab CE
  • Github

Terraform also supports different APIs, plugins, and modules.

7. What is Terraform Cloud?

Terraform Cloud is a remote development environment built for teams using Terraform. It helps large teams collaborate when using Terraform. It offers features like state locking, version control, private module registries, and policy controls.

8. What is Terraform Enterprise?

Terraform enterprise is a distribution of Terraform Cloud hosted by HashiCorp, the makers of Terraform. It is a paid service for companies, offering private instances of Terraform Cloud and additional features like SAML and audit logging.

9. What are some useful Terraform commands, and what do they do?

  • terraform init - initializes the directory you are currently in
  • terraform plan - creates a preview of planned changes to your infrastructure
  • terraform refresh - updates the Terraform state to sync with the settings from remote objects
  • terraform apply - runs the proposed Terraform plan on your infrastructure
  • terraform graph - creates a graph of your Terraform execution plan
  • Terraform -version - returns the Terraform version you are using
  • terraform destroy - terminates the objects that Terraform had built

10. What are some major Terraform competitors?

  • Packer
  • Saltstack
  • Ansible
  • Palumi
  • CloudFoundry

11. What are some important features of Terraform?

  • Change Automation - Terraform can automatically apply changesets to your infrastructure without requiring manual intervention by providing robust execution plans.
  • Execution plans - Terraform can automatically generate execution plans with suggestions for how changes to your infrastructure can be updated.
  • Resource Graphs - Terraform can produce graphs of your resources, providing a visual representation of your infrastructure.
  • Infrastructure as Code - Terraform enables DevOps teams to use HCL to describe their infrastructure and resources in human-readable code.

12. What are modules in Terraform?

A Terraform module is a container consisting of multiple resources that are used simultaneously. Modules are used to manage infrastructure in instances where multiple resources should be provisioned or changed at the same time.

13. When would you use modules in Terraform?

Terraform modules are useful when multiple resources need to be used at the same time. This allows you to group related resources together, maintain a logical and organized configuration, store objects consistently, and reuse code.

14. What is a child module?

In Terraform, a child module is a module that is run by another module.

15. Does Terraform support on-prem infrastructure?

Yes, Terraform can be used for infrastructure on premises. Terraform does not require cloud resources to work.

16. What is a Terraform Provisioner?

In Terraform, a provisioner runs scripts to create or delete a resource. Provisioners can be run on local or remote machines, but should only be executed in extreme circumstances.

17. What is a null resource?

In Terraform, a null resource is a resource containing provisioners that aren’t associated with any other resource. A null resource stops executing after the standard resource lifecycle is complete.

18. What are the stages of the Terraform workflow?

There are three stages to the Terraform workflow: Write, Plan and Apply.

In the Write stage, you define the resources in your infrastructure in your configuration files.

In the Plan stage, Terraform generates an execution plan outlining the objects and resources in your infrastructure that it will create, update or destroy. In this stage, you review the plan to ensure it will work as intended.

In the Apply stage, you approve the execution plan. Terraform will execute the proposed plan, creating, updating, or destroying resources as outlined in the Plan stage. Your infrastructure is provisioned and the state is updated.

19. What is a Resource Graph?

Terraform can produce a visual representation of an application’s infrastructure called a Resource Graph. The Resource Graph is a dependency graph showing how different objects in the application’s configuration relate to each other. Terraform’s Resource graph can create execution plans, refresh states, and more. This is an important tool for understanding and modifying the resources in an application using Terraform.

20. What is Terraform Core?

Terraform Core is the main Terraform binary. It interacts with Terraform plugins in order to configure and manage your application’s infrastructure. The Terraform Core interface is where you manage the providers and services your application requires.

21. What is a Terraform plugin?

Plugins are integral to how Terraform functions. Plugins are binaries executed by the core Terraform product that implement specific tools, like cloud platforms or provisioners. Configuring Terraform to work with the specific platforms that your application runs on will almost certainly require using plugins. They can make API calls, define resources, initialize libraries, and more.

22. What is a Provider?

In Terraform, a Provider is a type of plugin that connects with APIs such as cloud providers and SAAS software. They are integral to how Terraform configures infrastructure. Providers are what Terraform uses to implement all resources, no matter what type or where it is hosted. They are developed and maintained separately from the core Terraform product.

23. What is Sentinel?

Sentinel is a HashiCorp product that is distinct from Terraform, but it is often used with Terraform. It is a Policy as Code framework that allows DevOps teams to make logical policy decisions for their application using data from internal and external sources. Sentinel can be used with Terraform Cloud to define, manage, and enforce policies relating to their application’s execution plan, configuration, and state.

24. How would you store confidential information in Terraform?

If private credentials are needed in Terraform, it is best to treat the entire state as sensitive data. Local is stored as plain-text JSON, so storing state remotely is a good way to improve security.

25. What is State Locking?

State locking is a security feature that can freeze Terraform’s state and prevent any operations that could update it. When the state is locked, no one can change or corrupt it. Any operations that can write state can be locked automatically. Only certain backend environments support state locking.

26. What is Terragrunt?

Terragrunt is a tool for helping to reduce repetition when using Terraform to configure applications. It is developed by Gruntwork, and it is commonly used by DevOps teams who maintain multiple Terraform modules on AWS.

27. What is a tainted resource?

Objects in terraform can become degraded or broken. To replace these damaged objects, you can mark them as “tainted” and replace them in your next execution plan. When fixing a degraded object, you can use the “terraform apply” command to replace it with a new, working object.

28. What is a VPC?

VPC stands for Virtual Private Cloud. VPCs are privately operated cloud computing environments held within public clouds. With Terraform, you can use modules to create VPC resources in AWS. VPCs are commonly used when provisioning remote resources.

29. How do you use Terraform to collaborate?

Terraform uses version control to ensure safe, consistent workflows across large teams. With state locking, Terraform Cloud, role-based access settings, and private registries for modules and providers, it is easy to use Terraform to collaborate, even across large or multiple DevOps teams.

Tips for acing your Terraform interview

Of course, even if you know every Terraform interview question in the book, you might not land the job. It’s important to prepare for your interview as much as possible, even if you know all the answers. A bad interview can sink your candidacy, even if you are perfect for the role. When your interview is coming up, make sure to:

Practice

First, write down your answers to the Terraform interview questions you expect to be asked. Memorize them so you won’t be caught off guard.

Next, practice your answers by saying them out loud. Even if you are an expert, communicating your answers verbally can be a real challenge, especially in a stressful environment like a job interview.

To get your answers ready, practice them in the mirror or in your webcam so you can see how you look. Take note of your delivery, body language, and eye contact. It’s important to project confidence as you answer each question. If possible, do mock interviews with friends or family for a real interview experience.

Dress the part

Job interviews are no time to slack off. Make sure you wear clothes appropriate for a job interview, and appropriate for this specific company. If you’ve been unemployed for a long time, or at a company with a particular dress code, it can be difficult to know exactly what expectations will be at your next interview. To prepare for this, research the company to get a sense of their culture and how they dress in the office. Your answers to Terraform interview questions will be more compelling coming from someone who dresses the part.

Ask questions

If you are caught off guard by a Terraform interview question, don’t be afraid to ask for clarification. Interviewers want to understand your level of expertise, but they aren’t trying to trick you. There is no downside to making sure you’re on the same page before you begin your answer.

Even if you don’t know the answer, it can help to talk through your reaction to the question with the interviewer. They want to understand your thought process, even if you don’t know every specific detail about using Terraform. If you can show that you can think critically, work your way through difficult problems, and investigate topics that you aren’t familiar with, you can turn a Terraform interview question you can’t answer into a demonstration of your problem-solving ability.

Tell the truth

If you end up facing Terraform interview questions you really can’t answer, even after working through it, there is no point in trying to fake your way through it. Be honest about the aspects of Terraform that you aren’t familiar with, and indicate that you are enthusiastic to learn more about this tool. Besides, even if you get away with a lie, exaggerating your experience with Terraform will only lead to awkward moments later in the interview process when you have to do a technical interview.

Copyright © 2022 VisualCV

Terms of UsePrivacy Policy
Facebook
Twitter
LinkedIn