Terraform Interview Questions

1. What is Terraform?

Terraform is an open-source tool for provisioning and managing cloud infrastructure.​ Terraform helps in automating the Infra provisioning in Azure, AWS etc.​

2. Can you please explain the workflow of Terraform?

Once the development of the Terraform is complete, we need to run the below commands

  • Init
  • Validate
  • Plan
  • Apply
  • Destroy

2.1. What is Terraform Init Command?

The terraform init command is used to initialize a directory which contains our Terraform code files​.

2.2. What is Terraform Plan Command?

The terraform plan command is used to preview the changes.​

2.3. What is Terraform Apply Command?

The terraform apply command is used to apply the changes to Azure

2.4. What is Terraform Validate Command?

The terraform Validate command is used to validate code

2.5. What is Terraform Destroy Command?

The terraform Destroy command is used to delete services from Azure


3. What is Terraform provider?

Terraform provider is a kind of plugin that will let us interact with the provider. For ex: if you have to work with Azure, we need to use Azure Provider.

4. Can you explain / write on how to create a simple resource in Azure using Terraform?

resource "azurerm_resource_group" "rg“    {​
  name     =    "myTFResourceGroup"​
  location =    "eastus"​
   tags = {​
        environment = "Terraform Demo"​

5. What is the difference between variables and locals in Terraform

Variable: If you would like to pass a value to Terraform from outside then use Variables

Locals: These locals are internal to the Terraform file. We can’t pass them from outside world.


6. What are the various methods of passing inputs to Terraform?

There are 6 methods

  • Default Value
  • -var flag
  • -var-file flag
  • terraform.tfvars
  • .auto.tfvars
  • Environment Variable

7. What is State in Terraform? What is the significance?

  • It is important and mandatory to maintain State in Terraform
  • It is stored in JSON files
  • The filename is terraform.tsstate
  • The state file contains all the information about the infrastructure that Terraform has created. For ex: If terraform has created 10 resources in Azure, then all the information about those 10 services will be stored in the State file.
  • You can store the State either in Local File or Remote File

8. where is the State file located?

It will be created in the same folder where the root main.tf is located.

9. Does terraform State File contains any information about the Resources that are not created using Terraform?


10. What is Terraform Backend? And, how do you configure the Terraform backend?

Terraform use Backend to configure how to load the State.


11. What are different methods of storing the State?

Local State: By default the state is stored in the local drive.

Remote State: When working in a team or when you integrate Terraform with Azure DevOps, we need to rely on a service like Azure Blob Storage.

12. What are Terraform Modules? How can you modularize Terraform code?

Terraform modules are nothing but a folder which contain .tf files for a set of related services.

Modules help us in achieving reusability.

13. How do you invoke Child modules? And, how do you pass inputs to child modules?

module "ResourceGroup_Module" {
    source = "Path of the Module"
    <Paremeters assignments here >

Do you like this article? If you want to get more updates about these kind of articles, you can join my Learning Groups




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s