100% found this document useful (3 votes)
2K views11 pages

Terraform Interview Questions Guide

Terraform interview questions

Uploaded by

Jepra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
2K views11 pages

Terraform Interview Questions Guide

Terraform interview questions

Uploaded by

Jepra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Learn Cloud from Experts

MOST ASKED TERRAFORM


INTERVIEW QUESTIONS &
ANSWERS
1. Beginner Level

2. Intermediate Level

3. Advanced Level

[EDITION 01]

1. © Copyright 2021 | K21 Academy | All Rights Reserved Atul Kumar


Author & Cloud Expert
Learn Cloud from Experts

WHAT IS TERRAFORM?

Terraform is a tool to build an infrastructure safely and efficiently. Terraform can


manage leading and popular service providers as well as custom in-house solutions.

The Configuration file in Terraform describes the components needed to run a single
application or your entire datacenter. Terraform then generates an execution plan
describing what it will do to reach the desired state, and then executes it to build
the described infrastructure. It creates incremental execution plans which can be
applied according to the configuration change.

What is Hashicorp Certified: Terraform Associate?


The Terraform Associate is the Cloud Engineer specializing in operations, IT, or
developers who know the basic concepts and skills associated with open source
HashiCorp Terraform. This person understands which enterprise features exist and
what can and cannot be done using the open-source offering.

Below are some of the most asked Terraform interview questions for a Terraform
Associate role:

2. © Copyright 2021 | K21 Academy | All Rights Reserved FREE CLASS: https://k21academy.com/terraform02
Learn Cloud from Experts

1. BEGINNER LEVEL:
TERRAFORM INTERVIEW QUESTION

Question 1: What do you mean by Terraform?


Answer: Terraform is open-source communication as a system software tool created by HashiCorp. It is an
instrument for building, altering, and versioning transportation safely and professionally. Terraform can
direct existing and accepted service providers as well as convention in-house solutions.

Question 2: What are the reasons for choosing Terraform for DevOps?
Answer: Below are the reasons for choosing Terraform for DevOps:
It can do complete orchestration and not just configuration management (like Ansible and Puppet).
Has amazing support of almost all the popular cloud providers like AWS, Azure, GCP, DigitalOcean etc.
Easily manages the configuration of an immutable (dynamic) infrastructure.
Provide immutable infrastructure where configuration changes smoothly.
Works on HCL (HashiCorp configuration language), which is very easy to learn and understand.
Easily portable from one provider to another.
Easy Installation.

Question 3: Define Terraform init?


Answer: Terraform initializes the code using the command terraform init. This command is used to initialize
the working directory containing Terraform configuration files. It is safe to run this command multiple times.

You can use the init command for:

Plugin Installation
Child Module Installation
Backend Initialization

Question 4: Name some major competitors of Terraform?


Answer: Some of them are:
You can use the init command for:

Packer
Cloud Foundry
Ansible
Kubernetes

3. © Copyright 2021 | K21 Academy | All Rights Reserved FREE CLASS: https://k21academy.com/terraform02
Learn Cloud from Experts

Question 5: Define Terraform provider?


Answer: Terraform is used to manage and inform infrastructure resources such as bodily machines, VMs,
network switches, containers, and more. A provider is accountable for thoughtful API interactions and
revealing resources. Terraform supports a large number of cloud providers.

Question 6: How does Terraform work?


Answer: Terraform creates an implementation plan, define what it will do to attain the preferred state, and
then executes it to construct the described infrastructure. As the configuration changes, Terraform is talent-
ed to decide what changed and generate incremental execution plans which can be practical.

Question 7: Name some major features of Terraform?


Answer: Some of them are:
You can use the init command for:

Execution Plan
Change Automation
Resource Graph
Infrastructure as code

Question 8: Define IAC?


Answer: IaC is a short form to the term “Infrastructure as Code”. IaC refers to a scheme whereby develop-
ers can run and provision the computer data center’s mechanically instead of getting into a physical process.
Terraform, for example, is a case tool of IaC.
You can use the init command for:

Execution Plan
Change Automation
Resource Graph
Infrastructure as code

Question 9: How to check the installed version of Terraform?


Answer: We can use terraform -version of the command to identify the version which we are running.

4. © Copyright 2021 | K21 Academy | All Rights Reserved FREE CLASS: https://k21academy.com/terraform02
Learn Cloud from Experts

2. INTERMEDIATE LEVEL:
TERRAFORM INTERVIEW QUESTION

Question 1: Explain the uses of Terraform CLI and list some basic CLI commands?
Answer: The command-line interface to Terraform is via the terraform command, which accepts a variety
of subcommands such as terraform init or terraform plan.

Common commands:

terraform init: Prepare your working directory for other commands


terraform validate: Check whether the configuration is valid
terraform plan: Show changes required by the current configuration
terraform apply: Create or update infrastructure
terraform destroy: Destroy previously-created infrastructure

Question 2: How does Terraform help in discovering plugins?


Answer: The authority “Terraform init” helps Terraform interpret configuration files in the operational
directory. Then, Terraform finds out the essential plugins and searches for installed plugins in diverse loca-
tions. In addition, Terraform also downloads extra plugins at times. Then, it decides the plugin versions to
use and writes a security device file for ensuring that Terraform will employ the identical plugin versions.

Question 3: Can I add policies to the open-source or pro version of Terraform


enterprise?
Answer: You cannot insert policies to the open-source description of Terraform Enterprise. The equal also
goes for the Enterprise Pro version. The finest version of Terraform Enterprise only could contact the look-
out policies.

Question 4: Define Modules in Terraform?


Answer: A module in Terraform is a jug for numerous resources that are used jointly. The root module is
required for every Terraform that includes resources mentioned in the .tf files.

Question 5: What are the ways to lock Terraform module versions?


Answer: You can use the terraform module registry as a source and provide the attribute as ‘version’ in the
module in a terraform configuration file. If you are using the GitHub repository as a source, then you need
to specify the branch, version and query string with ‘? ref’.

5. © Copyright 2021 | K21 Academy | All Rights Reserved FREE CLASS: https://k21academy.com/terraform02
Learn Cloud from Experts

Question 6: What do you mean by Terraform cloud?


Answer: Terraform Cloud is an application that helps teams use Terraform together. It manages Terraform
runs in a consistent and reliable environment, and includes easy access to shared state and secret data,
access controls for approving changes to infrastructure, a private registry for sharing Terraform modules,
detailed policy controls for governing the contents of Terraform configurations, and more.

Question 7: Define null resource in Terraform?


Answer: The null resource implements the average resource lifecycle but takes no extra action. The trigger
argument permits specifying a subjective set of values that, when misrepresented will source the reserve to
be replaced.
The primary use-case for the null resource is as a do-nothing container for arbitrary actions taken by a
provisioner.

Question 8: Can Terraform be used for on-prem infrastructure?


Answer: Yes, Terraform can be utilized for on-prem infrastructure. There are a lot of obtainable providers.
You can decide any one of them which suits you most excellent. Many also build client Terraform providers
for themselves; all wanted is just an API.

6. © Copyright 2021 | K21 Academy | All Rights Reserved FREE CLASS: https://k21academy.com/terraform02
Learn Cloud from Experts

3. ADVANCED LEVEL:
TERRAFORM INTERVIEW QUESTION

Question 1: How would you recover from a failed apply in Terraform?


Answer: You can put your configuration in version control and commit before each change, and then you
can use your version control system’s features to revert to an older configuration if needed. You always
need to make sure that you recommit the previous version code for it to be the new version in the version
control system.

Question 2: What do you mean by Terragrunt, list some of its use cases?
Answer: Terragrunt is a thin wrapper that provides extra tools for keeping your configurations DRY, work-
ing with multiple Terraform modules, and managing remote state.

Use cases:

Keep your Terraform code DRY


Keep your remote state configuration DRY
Keep your CLI flags DRY
Execute Terraform commands on multiple modules at once
Work with multiple AWS accounts

Question 3: What steps should be followed for making an object of one module to
be available for the other module at a high level?
Answer: Following are the steps that should be followed for making an object of one module to be avail-
able for the other module at a high level:

1. First, an output variable to be defined in a resource configuration. Till you do not declare resource config-
uration details, the scope of local and to a module.
2. Now, you have to declare the output variable of module_A to be used in other module’s configuration. A
brand new and latest key name should be created by you and the value should be kept equivalent to the
module_A’s output variable.
3. Now, for module_B you have to create a file variable.tf. Establish an input variable inside this file having
exactly the same name as was in the key defined by you in module_B. In a module, this particular variable
enables the resource’s dynamic configuration. For making this variable available to some other module also,
replicate the process. This is because the particular variable established here have its scope restricted to
module_B.

7. © Copyright 2021 | K21 Academy | All Rights Reserved FREE CLASS: https://k21academy.com/terraform02
Learn Cloud from Experts

Question 4: What is State File Locking?


Answer: State file locking is a mechanism in terraform where operation on a specific state file is blocked to
avoid conflicts between multiple users performing the same operation. Once the lock from one user is
released, then only any other user can operate on that state file after taking a lock on it. This helps in
preventing any corruption of the state file. It is a backend operation, so the acquiring of lock on a state file
in backend. If it takes more time than expected to acquire a lock on the state file, you will get a status
message as an output.

Question 5: What is a Remote Backend in Terraform?


Answer: The remote backend in terraform is used to store the state of terraform and can also run opera-
tions in terraform cloud. Remote backend multiple terraform commands such as init, plan, apply, destroy
(terraform version >= v0.11.12), get, output, providers, state (sub-commands: list, mv, pull, push, rm, show) ,
taint, untaint, validate and many more. It can work with a single remote terraform cloud workspace or even
multiple workspaces. For running remote operations like terraform plan or terraform apply, you can use
terraform cloud’s run environment.

Question 6: What is a Tainted Resource?


Answer: Tainted resources are those resources that are forced to be destroyed and recreated on the next
apply command. When you mark a resource as tainted, nothing changes on infrastructure but the state file
is updated with this information(destroy and create). After marking a resource as tainted, terraform plan out
will show that the resource will get destroyed and recreated, and when the next apply happens the changes
will get implemented.

CONCLUSION
Terraform questions can be a little tricky sometimes so having knowledge about terraform is very crucial
before going for an interview. To test your knowledge on terraform, the best way is to appear for the certifi-
cation which will prepare you with some good questions and you will also earn a certification. More impor-
tantly, it will add credibility to your resume as well as give your confidence a boost.

8. © Copyright 2021 | K21 Academy | All Rights Reserved FREE CLASS: https://k21academy.com/terraform02
Learn Cloud from Experts

FREE CLASS

Register for our FREE Class To know about Cloud and DevOps Overview
and Cloud Automation Tools: Terraform, Cloud Formation, Ansible, Chef,
Puppet, why you should learn Terraform, Job opportunities for Terraform
Associate in the market, and what to study Including Hands-On labs you
must perform to clear Terraform Certification: Hashicorp Associate
so that you can stay ahead in your career and earn a lot more a
https://k21academy.com/terraform02

9. © Copyright 2021 | K21 Academy | All Rights Reserved FREE CLASS: https://k21academy.com/terraform02
Learn Cloud from Experts

“With the current success of Terraform, the cloud market has a lot of
requirements for DevOps engineers with good terraform knowledge
as it makes the deployment easy and efficient. If you are interested in
securing a terraform job for yourself but are not certain what type of
questions are asked in the interview then you are at the correct
Place.

This guide is prepared by


Oracle ACE, Author & Cloud Expert Atul Kumar from K21Academy.

ABOUT AUTHOR

Atul Kumar Is An Oracle ACE, Author & Oracle


Certified Cloud Architect With 20+ Years Experience.

He is helping his customer to become an expert in


Cloud Infrastructure Automation Certification:
Terraform Associate.

/oracleappsdba /k21academy /k21academy /k21academy /k21academy

10. © Copyright 2021 | K21 Academy | All Rights Reserved FREE CLASS: https://k21academy.com/terraform02
Learn Cloud from Experts

Learn Cloud from Experts

[email protected]

11. © Copyright 2021 | K21 Academy | All Rights Reserved FREE CLASS: https://k21academy.com/terraform02

You might also like