Terraform Interview Questions
- Dhanush Kuppusamy
- 15th Feb, 2022
- 777 Followers
Latest Interview Questions
Pratice HR Questions
Terraform is a code software tool that enables users to create, change, and improve infrastructure with safety and predictability. It was created by HashiCorp which uses high-level configuration language known as Hashicorp Configuration Language and JSON. Terraform found widespread application in Amazon Web Services, IBM Cloud, Google Cloud, Platform, DigitalOcean, Linode, Microsoft Azure, Oracle Cloud Infrastructure, OVH, VMware, vSphere, OpenNebula, OpenStack
Terraform Interview Questions
1) What is Terraform?
Terraform is an open-source infrastructure as code software tool created by HashiCorp. It enables users to define and provision a datacenter infrastructure using a high-level configuration language known as Hashicorp Configuration Language, or optionally JSON.
2) Enlist major features of Terraform?
The key features of Terraform are
- Infrastructure as Code (IAC)
- Execution Plans
- Change Automation
- Resource Graph
3) Why Terraform is preferred for DevOps?
There are a bunch of reasons for giving preference to Terraform to be used as one of the significant tools of DevOps. The main motive of DevOps is to bring efficiency and quality in software delivery. For this, some tools are required for making the delivery smoother, faster and efficient. Here, terraform comes to the limelight where it aids organizations in automating and also aids with infrastructure as code. Terraform is helpful with its availability of implementing every type of coding principle. The extraordinary feature of terraforming includes its quickness and the operations performed by it. These are some of the important reasons for which Terraform is gaining popularity and attention in the organizations.
4) What is terraform in aws?
Terraform by HashiCorp, an AWS Partner Network (APN) Advanced Technology Partner and member of the AWS DevOps Competency, is an "infrastructure as code" tool similar to AWS CloudFormation that allows you to create, update, and version your Amazon Web Services (AWS) infrastructure.
5) What does HCL stand for?
In Terraform HCL stands for HashiCorp Configuration Language. It is a configuration language built by HashiCorp that is used to build a structured configuration language that is both human and machine-friendly for use with command-line tools but specifically targeted towards DevOps tools, servers, etc.
6) Explain the architecture of terraform?
The architecture of terraform consists of following components:
- CLI (Command Line interface)
- Backends for executing operations,storing state, and storing workspace-defined variables
- Configuration Loader
- State Manager
- Graph Builder
- Graph Walk
- Vertex Evaluation
- Expression Evaluation
7) List some major competitors of terraform?
Ansible, Kubernetes, Packer, Cloud Foundry, and Pulumi are the most popular alternatives and competitors to Terraform.
8) In which programming language Terraform is written?
Terraform is an open-source tool created by HashiCorp and written in the Go programming language.
9) What is use of Terraform CLI? Enlist few major command.
The terraform CLI is a well-behaved command-line application. It is used to run commands for terraforming.
Below are few common Terraform commands:
- Apply: builds or changes infrastructure.
- Console: Interactive console for Terraform interpolations.
- destroy: Destroy Terraform-managed infrastructure.
- env: Workspace management
- fmt: Rewrites config files to canonical format
- get: Download and install modules for the configuration
- graph: Build a visible graph of Terraform resources Import: existing infrastructure into Terraform
- Init: Initialize a Terraform working directory
- output: Read output from a state file plan: Generate and show an execution plan validate: Validates the Terraform files
- version: Prints the Terraform version
- Workspace: Workspace management
10) What is a provider in Terraform? Enlist some Terraform Providers.
Terraform provider is responsible for understanding API interactions and exposing resources. Providers generally are an IaaS (e.g. Alibaba Cloud, AWS, GCP, Microsoft Azure, OpenStack), PaaS (e.g. Heroku), or SaaS services (e.g. Terraform Cloud, DNSimple, Cloudflare).
Some Terraform providers are:
- IaaS services: Examples are Alibaba Cloud, AWS, GCP, Microsoft Azure, OpenStack.
- PaaS services: Examples are Heroku.
- SaaS services: examples are Terraform Cloud, Cloudflare, DNSimple.
11) For what provisioners are used in Terraform?
Provisioners in Terraform can be used to prepare servers or other infrastructure objects for service. It models specific actions on the local machine as well as on remote machines.
12) Enlist some Built-in Provisioners available in Terraform?
Below is the list of some Built-in provisioners in Terraform:
- Chef Provisioner
- File Provisioner
- Habitat Provisioner
- Local-exec Provisioner
- Puppet Provisioner
- Remote-exec Provisioner
- Salt-masterless Provisioner
13) What are Modules in Terraform?
A module in Terraform is a container for several resources that are used together. The root module is compulsory for every terraform that includes resources mentioned in the .tf files.
14) What is Terraform cloud? Enlist few features provided by it?
Terraform Cloud is an application that let the teams use the Terraform together. It runs in a reliable environment and includes easy access to shared state and secret data. It provides access controls for adopting changes to infrastructure and a private registry for sharing terraform modules.
Features of the Terraform cloud are:
- Audit logging
- SAML single sign-on.
15) How to check installed version of Terraform?
To check the installed version of Terraform, use the below command:
16) What do you mean by IAC in Terraform?
IAC is an abbreviation to the term "Infrastructure as Code". IaC refers to a system whereby developers can manage and provision the computer data centers automatically instead of getting into a manual process. Terraform, for instance, is an example tool of IaC.
17) Can terraform be used for on-prem infrastructure?
Yes, Terraform can be used for on-prem infrastructure. There are many providers that are available. you can choose any one of them which suits you best. Many also build customer terraform providers for themselves, all needed is just an API.
18) What is Oracle Cloud Infrastructure?
Oracle Cloud is a cloud computing service offered by Oracle Corporation providing servers, storage, network, applications and services through a global network of Oracle Corporation managed data centers. The company allows these services to be provisioned on-demand over the Internet.
19) How to create dependency between modules in terraform?
In Terraform dependencies are normally created automatically by references, rather than explicitly using depends_on. In terraform, there is no way to use depends_on variables.
20) How do you deal with versioning in Terraform?
Semantic Versioning of Models should be used. Apply should only be done with Versioned modules/tags.
21) What is used of terraform apply command?
The Terraform apply command is used to apply the changes required to reach the desired state of the configuration, or the pre-determined set of actions generated by a terraform plan execution plan.
22) What is the different between Platform.sh and Terraform?
Platform.sh and Terraform are similar in that they both subscribe to the idea of "infrastructure as code".
Platform.sh is a second-generation Platform-as-a-Service built especially for continuous deployment. It allows you to host web applications on the cloud while making your development and testing workflows more productive whereas Terraform is an open-source infrastructure as code software tool that enables users to define and provision a data center infrastructure using a high-level configuration language known as Hashicorp Configuration Language, or optionally JSON
23) What is Software Defined Networking?
Software-defined networking (SDN) technology is an approach to network management that enables dynamic, programmatically efficient network configuration in order to improve network performance and monitoring making it more like cloud computing than traditional network management
24) Which command is used to destroy Terraform-managed infrastructure?
Terraform destroy command is used to destroy the Terraform-managed infrastructure.
terraform destroy [options] [dir]
25) What is use of fmt command in Terraform?
The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style. This command applies a subset of the Terraform language style conventions, along with other minor adjustments for readability.
terraform fmt [options] [DIR]
26) What does the providers command do?
The terraform providers command prints information about the providers used in the current configuration.
terraform providers [config-path]
27) What is Terragrunt?
Terragrunt is a thin wrapper for Terraform that implements the practices advocated by the Terraform: Up and Running book. We've found Terragrunt helpful as it encourages versioned modules and reusability for different environments with some handy features, including recursive code execution in subdirectories.
28) What is terraform state?
Terraform state is a command that is used for advanced state management. The state is a necessary requirement for Terraform to function. Terraform must store state about your managed infrastructure and configuration. This state is used by Terraform to map real-world resources to your configuration, keep track of metadata, and to improve performance for large infrastructures. Syntax
terraform state [options] [args]
29) What is terraform init?
The terraform init is a command that is used to initialize a working directory containing Terraform configuration files. This is the first command that should be run after writing a new Terraform configuration or cloning an existing one from version control. It is safe to run this command multiple times.
terraform init [options] [DIR]
30) What is terraform backend?
A "backend" in Terraform determines how the state is loaded and how an operation such as apply is executed. This abstraction enables non-local file state storage, remote execution, etc.
By default, Terraform uses the "local" backend, which is the normal behavior of Terraform you're used to