TeachingBee

Most Frequently Asked Terraform Interview Questions

Terraform Interview Questions

Terraform helps to define cloud and on-prem resources using configuration file that are readable by humans.It provides version control, consistent workflow to provision and manage all of your infrastructure. So if you are appearing for dev ops role interview, there are high chances interviewer can asked these Terraform Interview Questions.

Let’s look at some of the most Frequently asked Terraform Interview Questions.

Terraform Interview Questions.

1. What are the most useful Terraform commands?

Some of the important terraform commands are:

CommandFunction it performs
terraform initPrepare your working directory for other commands
terraform planShow changes required by the current configuration
terraform applyCreate or update infrastructure
terraform destroyDestroy previously-created infrastructure
Terraform Interview Questions: Terraform commands

2. What do you mean by term null resource in Terraform?

Null Resource: It allows to configure provisioners not directly associated with a single existing resource. It follows standard lifecycle and can configure provisioners, connection details, and other meta-parameters like other resources but it doesn’t take additional actions. The null resource’s primary application is as a do-nothing container for arbitrary actions performed by a provisioner.

3. What does the command terraform validate do?

Terraform validate command examines configuration file and inspects whether it is syntactically correct and internally consistent, regardless of variables or current state. It can be executed automatically, such as a post-save check in a text editor or a test step in a continuous integration system for a reusable module.

4. Explain State File Locking?

To prevent multiple concurrent operations from different users on same file and to prevent file from being corrupt, terraform uses state file locking mechanism.Unless the lock has not been released, other users cannot perform operations on it.

5. What are the components that makeup Terraform’s architecture?

Terraform Interview Questions: Components Of Terraform's architecture

The following components are included in the Terraform architecture:

Sub-graphs
Evaluation of Expression
Evaluation of the Vertex
Configuration Loader
CLI (Common Line Interface)
Backend
Walk the Graph
Builder of Graphs
State Manager
Terraform Interview Questions: Components Of Terraform’s architecture

6. What are the different degrees of Sentinel policing?

Various degrees of Sentinel policing are

PolicyRoles
AdvisoryWhen a user initiates a plan that violates the rules, an advisory is sent.
Soft MandatoryUnless an override is stated, the policy must pass. Overrides are only available to administrators.
Hard MandatoryThe policy must pass regardless of the circumstances. Unless it is abolished, this policy cannot be overridden
Terraform Interview Questions: Degrees of Sentinel policing

7. What is the use case of Terraform State?

Terraform State maps resources to the configuration thus helping in performance improvement when planning changes for complex infrastructures.

8. Define Provisioners in Terraform?

Provisioners are Terraform resources used to execute scripts as a part of the resource creation or destruction. There are two types of Provisioners in Terraform:

local-execIt invokes a script on the machine running Terraform.
remote- execInvokes a script on a remote resource after it is created.
Terraform Interview Questions: Provisioners

9. What happens when multiple engineers start deploying infrastructure using the same state file?

Terraform have mechanism called state file locking to prevent such scenarios and prevents the state file from getting corrupt.

10. Which command can be used to preview the terraform execution plan?

The terraform plan command generates the execution plan of the changes Terraform will do to the infrastructure.

11. Differentiate between Terraform and Ansible.

FeatureTerraformAnsible
PurposeProvisioning and orchestrationConfiguration and adding software
ApproachIt follows a declarative Infrastructure as a Code approach.It follows a procedural approach.
NetworkBest for building services from the ground upWorks best on an existing network
MutableNoYes
Packaging and TemplatingIt does not provide better support in terms of packaging and templating.It provides full support for packaging and templating.
Lifecycle ManagementDepends on lifecycle or state management.Does not have lifecycle management at all.
Terraform Interview Questions: Terraform vs Ansible

12. How does Terraform control and handle rollbacks ?

To control and handle rollbacks:

  1. Recommit the previous code version to make it the new and current one
  2. Because Terraform is more declarative, make sure that everything in the code reverts to its previous state.
  3. If the state file becomes corrupted, we would use Terraform Enterprise’s State Rollback feature to restore the previous state

Conclusion

In this article we most Frequently asked Terraform Interview Questions.

Checkout Other commonly asked questions here

Got a question or just want to chat? Comment below or drop by our forums, where a bunch of the friendliest people you’ll ever run into will be happy to help you out!

90% of Tech Recruiters Judge This In Seconds! 👩‍💻🔍

Don’t let your resume be the weak link. Discover how to make a strong first impression with our free technical resume review!

Related Articles

uses of computer network

Important Uses Of Computer Network

In this article we will see an overview of computer networks, various uses of computer network and its applications, and key technologies involved in computer networking. So, let’s begin. What

AWS Lambda Interview Questions-teachingbee

Important AWS Lambda Interview Questions And Answers

In today’s fast-paced tech landscape, AWS Lambda has emerged as a game-changer in serverless computing. As organizations increasingly shift towards serverless architectures, mastering AWS Lambda is becoming a crucial skill

Why Aren’t You Getting Interview Calls? 📞❌

It might just be your resume. Let us pinpoint the problem for free and supercharge your job search. 

Newsletter

Don’t miss out! Subscribe now

Log In