- What is Sentinel?
- In case something goes wrong, how will you handle and control rollbacks?
- What is Terraform cloud?
- Explain the use of the terraform apply command.
- What is Terraform State?
- What are providers in Terraform?
- What is terraform init?
- Explain the terraform core.
- What is main TF in terraform?
- Explain State File Locking with respect to Terraform.
- Can we use Terraform for an on-prem infrastructure?
- Why is Terraform used for DevOps?
- What are the disadvantages of maintaining the Terraform state file on the local machine?
- What are the key features of Terraform?
- What is private module registry?
- Explain the use of the terraform version command.
- How to store sensitive data/ credentials in Terraform?
- Is Terraform cloud-agostic?
Terraform Interview Questions and Answers (2023)
In this post, we put together the top Terraform interview questions and answers for beginner, intermediate and experienced candidates. These most important questions are categorized for quick browsing before the interview or to act as a detailed guide on different topics in Terraform interviewers look for.
Terraform Interview Questions
What is Sentinel?
View answer
Sentinel is the policy enforcement language used by HashiCorp. Sentinel policies are validated when the Terraform plan is executed. Sentinel will detect incorrect settings before they reach production.
In case something goes wrong, how will you handle and control rollbacks?
View answer
The usual way to represent "rolling back" in Terraform is to 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. Not all changes can be rolled back purely by reverting a VCS change though.
What is Terraform cloud?
View answer
The Terraform cloud is a collaboration tool for teams using Terraform. It is a platform that can make teams use Terraform together, either on-demand or in response to various events.
Explain the use of the terraform apply command.
View answer
Terraform apply command is used to create or introduce changes to real infrastructure. By default, apply scans the current working directory for the configuration and applies the changes appropriately.
What is Terraform State?
View answer
Terraform keeps track of the resources it has created in a state file. This crucial file contains all of the information Terraform requires to change, update, and delete infrastructure.
What are providers in Terraform?
View answer
A provider is a Terraform plugin that allows users to manage an external API. Provider plugins like the AWS provider or the cloud-init provider act as a translation layer that allows Terraform to communicate with many different cloud providers, databases, and services.
What is terraform init?
View answer
The terraform init command creates a working directory in which Terraform configuration files can be found.
Explain the terraform core.
View answer
Terraform Core oversees the reading and interpolation of resource plan executions, resource graphs, state management features and configuration files. Core is composed of compiled binaries written in the Go programming language.
What is main TF in terraform?
View answer
main.tf contains the primary configuration for your module.
Explain State File Locking with respect to Terraform.
View answer
Without locking, if two team members are running Terraform at the same time, you may run into race conditions as multiple Terraform processes make concurrent updates to the state files, leading to conflicts, data loss, and state file corruption.
Can we use Terraform for an on-prem infrastructure?
View answer
Yes, Terraform is usable for an on-prem infrastructure as it allows a lot of obtainable providers which we can choose according to the best usage by using an API.
Why is Terraform used for DevOps?
View answer
Terraform is preferred for DevOps because it allows us to manage infrastructure as code. The infrastructure as code is the foundation for DevOps practices such as continuous integration, version control, continuous deployment, and code review.
What are the disadvantages of maintaining the Terraform state file on the local machine?
View answer
- State file could contain sensitive data
- Inability to collaborate
- On a local machine, there is a chance of losing the state file.
- There is no centralised record keeping to track historical developments
What are the key features of Terraform?
View answer
Terraform helps you manage all of your infrastructure as code and construct it as and when needed.
Key features:
- Console that allows users to observe functions
- Ability to translate HCL code into JSON format
- A configuration language that supports interpolation
- A module count that keeps track of the number of modules applied to the infrastructure
What is private module registry?
View answer
Terraform Cloud allows you to create and confidentially share infrastructure modules within an organization using the private module registry. With Terraform Enterprise, the private module registry allows you to share modules within or across organizations.
Explain the use of the terraform version command.
View answer
The terraform version command shows the current Terraform version as well as any installed plugins
How to store sensitive data/ credentials in Terraform?
View answer
Sensitive Variable is Secure Place for API Credentials: Terraform Cloud can securely store and encrypt passwords. This encrypted storage can be used to store passwords, TLS certificates, SSH keys, and anything else that shouldn't be stored in plain text.
Is Terraform cloud-agostic?
View answer
Yes, Terraform is cloud-agostic and allows a single configuration to manage multiple providers and handle cross-cloud dependencies. It is also used to simplify management and orchestration, facilitates operators to build large-scale multi-cloud infrastructures.