π₯ Top 20 Terraform Interview Questions (Quick Fire Round)

1. What is Terraform?
Terraform is an Infrastructure as Code (IaC) tool by HashiCorp that automates provisioning of infrastructure using code.
2. Which language does Terraform use?
Terraform uses HCL (HashiCorp Configuration Language).
3. What is the difference between Terraform and Ansible?
Terraform provisions infrastructure (IaC), while Ansible configures it (CM β configuration management).
4. What are Terraform providers?
Providers are plugins that allow Terraform to interact with cloud services (AWS, Azure, GCP, etc.).
5. What is Terraform state?
Terraform state (terraform.tfstate
) maps resources in your configuration to real-world infrastructure.
6. How do you manage Terraform state in teams?
Use remote backends like AWS S3 with DynamoDB for state locking.
7. What is the difference between terraform plan
and terraform apply
?
plan
β Preview what will change.apply
β Executes the changes.
8. How do you destroy infrastructure in Terraform?
Run terraform destroy
.
9. What is the difference between terraform import
and terraform taint
?
import
β Bring existing infra under Terraform management.taint
β Mark resource for recreation in next apply.
10. What is a Terraform module?
A reusable container of multiple resources (e.g., VPC module).
11. What is a root module?
The main working directory where Terraform starts execution.
12. What are Terraform workspaces used for?
To manage multiple environments (dev, staging, prod) with the same configuration.
13. What is terraform init
used for?
It initializes a working directory by downloading providers and modules.
14. How do you pass values to variables?
Via .tfvars
file, CLI arguments, or environment variables.
15. What is the difference between local-exec and remote-exec provisioners?
local-exec
β Runs commands locally.remote-exec
β Runs commands on the created resource.
16. Can Terraform work with multiple providers in the same config?
Yes, you can configure multiple providers in one Terraform project.
17. What is the difference between count
and for_each
in Terraform?
count
β Creates multiple identical resources.for_each
β Creates resources from a map or set.
18. How do you upgrade Terraform provider plugins?
Run terraform init -upgrade
.
19. What is terraform refresh
used for?
To sync Terraform state with real infrastructure.
20. Whatβs the difference between mutable and immutable infrastructure in Terraform?
Mutable β Updated in-place (risky).
Immutable β Destroy and recreate resources (safer, preferred).
Subscribe to my newsletter
Read articles from AKHIL JONNALAGADDA directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
