Top 100+ Most Asked Terraform Interview Questions
Comprehensive technical guide covering Terraform HCL, State Management, Modules, Providers, and CI/CD best practices.
0%
Overall Progress
0/141
Status
Problem
Level
2.What is Terraform's primary purpose?Easy
2.What is Terraform's primary purpose?
Easy
3.What is Infrastructure as Code (IaC) and its main benefits?Easy
3.What is Infrastructure as Code (IaC) and its main benefits?
Easy
4.Explain the difference between declarative and imperative IaC.Medium
4.Explain the difference between declarative and imperative IaC.
Medium
5.What makes Terraform a cloud-agnostic tool?Medium
5.What makes Terraform a cloud-agnostic tool?
Medium
6.How does Terraform differ from configuration management tools like Ansible?Medium
6.How does Terraform differ from configuration management tools like Ansible?
Medium
7.What is the difference between Terraform and CloudFormation?Medium
7.What is the difference between Terraform and CloudFormation?
Medium
8.Who are some key players that compete with Terraform in the infrastructure as code (IaC) market?Medium
8.Who are some key players that compete with Terraform in the infrastructure as code (IaC) market?
Medium
9.Can Terraform be utilized to manage infrastructure that is hosted on-premises?Medium
9.Can Terraform be utilized to manage infrastructure that is hosted on-premises?
Medium
10.Could you describe the different parts that make up Terraform's architecture?Hard
10.Could you describe the different parts that make up Terraform's architecture?
Hard
11.Explain the basic structure of a Terraform configuration file.Easy
11.Explain the basic structure of a Terraform configuration file.
Easy
12.What are the main Terraform configuration files?Easy
12.What are the main Terraform configuration files?
Easy
13.What is a Terraform provider?Easy
13.What is a Terraform provider?
Easy
14.What are Terraform providers and resources?Easy
14.What are Terraform providers and resources?
Easy
15.What is a resource in Terraform?Easy
15.What is a resource in Terraform?
Easy
16.What is a data source in Terraform?Medium
16.What is a data source in Terraform?
Medium
17.What is the difference between a resource and a data source?Medium
17.What is the difference between a resource and a data source?
Medium
18.Describe the core Terraform workflow.Easy
18.Describe the core Terraform workflow.
Easy
19.What is the purpose of terraform init?Easy
19.What is the purpose of terraform init?
Easy
20.What does terraform init do?Easy
20.What does terraform init do?
Easy
21.Explain what terraform plan does and why it's important.Medium
21.Explain what terraform plan does and why it's important.
Medium
22.What is terraform apply?Easy
22.What is terraform apply?
Easy
23.What is the difference between terraform apply and terraform apply tfplan?Medium
23.What is the difference between terraform apply and terraform apply tfplan?
Medium
24.What does terraform destroy do?Easy
24.What does terraform destroy do?
Easy
25.What are the roles of terraform validate and terraform fmt?Easy
25.What are the roles of terraform validate and terraform fmt?
Easy
26.What is the function of terraform refresh?Medium
26.What is the function of terraform refresh?
Medium
27.What is the terraform state command used for?Medium
27.What is the terraform state command used for?
Medium
28.What is the purpose of the terraform graph command?Medium
28.What is the purpose of the terraform graph command?
Medium
29.What does terraform taint do?Medium
29.What does terraform taint do?
Medium
30.What is the difference between terraform plan and terraform apply?Easy
30.What is the difference between terraform plan and terraform apply?
Easy
31.What is the purpose of the Terraform state file?Medium
31.What is the purpose of the Terraform state file?
Medium
32.What is terraform.tfstate?Easy
32.What is terraform.tfstate?
Easy
33.Why is storing state remotely a best practice?Medium
33.Why is storing state remotely a best practice?
Medium
34.What are remote backends in Terraform?Medium
34.What are remote backends in Terraform?
Medium
35.How do you manage remote state in Terraform?Medium
35.How do you manage remote state in Terraform?
Medium
36.What is state locking and why is it important for collaboration?Hard
36.What is state locking and why is it important for collaboration?
Hard
37.How can you lock the Terraform state file?Medium
37.How can you lock the Terraform state file?
Medium
38.How do you manage state locking and concurrency issues in Terraform when working with large teams?Hard
38.How do you manage state locking and concurrency issues in Terraform when working with large teams?
Hard
39.How can you secure sensitive data within the Terraform state file?Hard
39.How can you secure sensitive data within the Terraform state file?
Hard
40.What happens if you manually edit the terraform.tfstate file?Hard
40.What happens if you manually edit the terraform.tfstate file?
Hard
41.How does Terraform handle resource drift?Medium
41.How does Terraform handle resource drift?
Medium
42.What are the different backend types available in Terraform?Medium
42.What are the different backend types available in Terraform?
Medium
43.What are variables in Terraform?Easy
43.What are variables in Terraform?
Easy
44.How do you define variables in Terraform?Easy
44.How do you define variables in Terraform?
Easy
45.Explain the difference between input variables and local variables (locals).Medium
45.Explain the difference between input variables and local variables (locals).
Medium
46.What are three common ways to assign values to Terraform variables?Medium
46.What are three common ways to assign values to Terraform variables?
Medium
47.What is a .tfvars file and how is it used?Easy
47.What is a .tfvars file and how is it used?
Easy
48.What are the different variable types in Terraform?Medium
48.What are the different variable types in Terraform?
Medium
49.How do you pass variables to Terraform?Easy
49.How do you pass variables to Terraform?
Easy
50.What is the precedence order for variable assignment in Terraform?Medium
50.What is the precedence order for variable assignment in Terraform?
Medium
51.What are environment variables in Terraform?Medium
51.What are environment variables in Terraform?
Medium
52.What is the purpose of output values in Terraform?Easy
52.What is the purpose of output values in Terraform?
Easy
53.How do you define outputs in Terraform?Easy
53.How do you define outputs in Terraform?
Easy
54.When would you use output values?Medium
54.When would you use output values?
Medium
55.How do you use conditional expressions in Terraform?Medium
55.How do you use conditional expressions in Terraform?
Medium
56.How can you conditionally create a resource in Terraform?Medium
56.How can you conditionally create a resource in Terraform?
Medium
57.What is the count meta-argument?Easy
57.What is the count meta-argument?
Easy
58.What is the for_each meta-argument?Medium
58.What is the for_each meta-argument?
Medium
59.What is the difference between the count and for_each meta-arguments?Hard
59.What is the difference between the count and for_each meta-arguments?
Hard
60.When would you choose for_each over count?Medium
60.When would you choose for_each over count?
Medium
61.What are dynamic blocks and provide a common use case?Hard
61.What are dynamic blocks and provide a common use case?
Hard
62.What is a Terraform module and why are they used?Medium
62.What is a Terraform module and why are they used?
Medium
63.Describe the typical file structure of a Terraform module.Medium
63.Describe the typical file structure of a Terraform module.
Medium
64.What is the difference between a root module and a child module?Medium
64.What is the difference between a root module and a child module?
Medium
65.How do you call a module in Terraform?Easy
65.How do you call a module in Terraform?
Easy
66.Why is it important to lock module versions, and how do you do it?Hard
66.Why is it important to lock module versions, and how do you do it?
Hard
67.How do you handle module versioning in Terraform?Hard
67.How do you handle module versioning in Terraform?
Hard
68.What are some best practices for Terraform module development?Hard
68.What are some best practices for Terraform module development?
Hard
69.How do you reuse code across multiple Terraform projects?Medium
69.How do you reuse code across multiple Terraform projects?
Medium
70.Where can you store and reference Terraform modules?Easy
70.Where can you store and reference Terraform modules?
Easy
71.What is the Terraform Registry?Easy
71.What is the Terraform Registry?
Easy
72.How does Terraform handle dependencies between resources?Medium
72.How does Terraform handle dependencies between resources?
Medium
73.What is implicit dependency in Terraform?Easy
73.What is implicit dependency in Terraform?
Easy
74.What is explicit dependency in Terraform?Medium
74.What is explicit dependency in Terraform?
Medium
75.How do you create explicit dependencies using depends_on?Easy
75.How do you create explicit dependencies using depends_on?
Easy
76.What is the lifecycle block in Terraform?Hard
76.What is the lifecycle block in Terraform?
Hard
77.What is the purpose of the lifecycle block in a resource?Medium
77.What is the purpose of the lifecycle block in a resource?
Medium
78.What are the different lifecycle arguments available?Hard
78.What are the different lifecycle arguments available?
Hard
79.What are Terraform workspaces and how do they differ from modules?Hard
79.What are Terraform workspaces and how do they differ from modules?
Hard
80.When would you use Terraform workspaces?Medium
80.When would you use Terraform workspaces?
Medium
81.How do you create and switch between workspaces?Easy
81.How do you create and switch between workspaces?
Easy
82.What is the default workspace in Terraform?Easy
82.What is the default workspace in Terraform?
Easy
83.What are Terraform provisioners, and why are they considered a 'last resort'?Hard
83.What are Terraform provisioners, and why are they considered a 'last resort'?
Hard
84.What is the difference between local-exec and remote-exec provisioners?Medium
84.What is the difference between local-exec and remote-exec provisioners?
Medium
85.When would you use a provisioner?Medium
85.When would you use a provisioner?
Medium
86.What are the types of provisioners in Terraform?Easy
86.What are the types of provisioners in Terraform?
Easy
87.How do you import existing infrastructure into Terraform?Hard
87.How do you import existing infrastructure into Terraform?
Hard
88.What is the terraform import command?Medium
88.What is the terraform import command?
Medium
89.What is a null_resource in Terraform?Hard
89.What is a null_resource in Terraform?
Hard
90.What is the difference between null_resource and regular resources?Medium
90.What is the difference between null_resource and regular resources?
Medium
91.What is the difference between null_resource and regular resources?Medium
91.What is the difference between null_resource and regular resources?
Medium
92.What is a resource target in Terraform and how is it used?Hard
92.What is a resource target in Terraform and how is it used?
Hard
93.How do you perform a rolling update in Terraform?Hard
93.How do you perform a rolling update in Terraform?
Hard
94.How can Terraform handle and disregard duplicate resource errors when executing a terraform apply command?Hard
94.How can Terraform handle and disregard duplicate resource errors when executing a terraform apply command?
Hard
95.What is Terraform Cloud?Easy
95.What is Terraform Cloud?
Easy
96.What is the difference between Terraform Cloud and Terraform Enterprise?Medium
96.What is the difference between Terraform Cloud and Terraform Enterprise?
Medium
97.What are the benefits of using Terraform Cloud?Easy
97.What are the benefits of using Terraform Cloud?
Easy
98.What is Sentinel in Terraform?Hard
98.What is Sentinel in Terraform?
Hard
99.What is policy as code in Terraform?Medium
99.What is policy as code in Terraform?
Medium
100.How do you manage multiple providers in a single Terraform configuration?Medium
100.How do you manage multiple providers in a single Terraform configuration?
Medium
101.How do you configure multiple provider instances?Medium
101.How do you configure multiple provider instances?
Medium
102.What is provider aliasing?Easy
102.What is provider aliasing?
Easy
103.How do you implement custom Terraform providers, and when would you need one?Expert
103.How do you implement custom Terraform providers, and when would you need one?
Expert
104.What is the Terraform Plugin SDK?Expert
104.What is the Terraform Plugin SDK?
Expert
105.How should you manage sensitive information in Terraform?Hard
105.How should you manage sensitive information in Terraform?
Hard
106.How do you handle secrets in Terraform?Hard
106.How do you handle secrets in Terraform?
Hard
107.What are some security best practices for Terraform?Medium
107.What are some security best practices for Terraform?
Medium
108.How can you secure the Terraform state file?Hard
108.How can you secure the Terraform state file?
Hard
109.What is the principle of least privilege in Terraform?Medium
109.What is the principle of least privilege in Terraform?
Medium
110.How do you debug and troubleshoot Terraform configurations?Medium
110.How do you debug and troubleshoot Terraform configurations?
Medium
111.What environment variables can help with debugging Terraform?Medium
111.What environment variables can help with debugging Terraform?
Medium
112.How do you enable verbose logging in Terraform?Easy
112.How do you enable verbose logging in Terraform?
Easy
113.What is TF_LOG and how do you use it?Easy
113.What is TF_LOG and how do you use it?
Easy
114.How do you integrate Terraform with CI/CD pipelines?Medium
114.How do you integrate Terraform with CI/CD pipelines?
Medium
115.What are the best practices for running Terraform in a CI/CD pipeline?Hard
115.What are the best practices for running Terraform in a CI/CD pipeline?
Hard
116.How do you automate Terraform deployments?Medium
116.How do you automate Terraform deployments?
Medium
117.What are Terraform functions?Easy
117.What are Terraform functions?
Easy
118.What are some commonly used Terraform functions?Medium
118.What are some commonly used Terraform functions?
Medium
119.How do you use the lookup function?Easy
119.How do you use the lookup function?
Easy
120.How do you use the concat function?Medium
120.How do you use the concat function?
Medium
121.What is the file function used for?Easy
121.What is the file function used for?
Easy
122.How do you test Terraform configurations?Hard
122.How do you test Terraform configurations?
Hard
123.What tools are available for testing Terraform code?Medium
123.What tools are available for testing Terraform code?
Medium
124.What is Terratest?Expert
124.What is Terratest?
Expert
125.How do you perform unit testing in Terraform?Hard
125.How do you perform unit testing in Terraform?
Hard
126.Scenario 1: Handling Manual Changes Outside Terraform. How can you detect and reconcile this change?Medium
126.Scenario 1: Handling Manual Changes Outside Terraform. How can you detect and reconcile this change?
Medium
127.Scenario 2: A developer mistakenly removed a resource from the config. How can you prevent accidental deletions?Medium
127.Scenario 2: A developer mistakenly removed a resource from the config. How can you prevent accidental deletions?
Medium
128.Scenario 3: Multiple engineers are applying changes on a shared project causing state conflicts. How can you prevent this?Hard
128.Scenario 3: Multiple engineers are applying changes on a shared project causing state conflicts. How can you prevent this?
Hard
129.Scenario 4: Your configuration needs database credentials. How should you store and manage sensitive information?Hard
129.Scenario 4: Your configuration needs database credentials. How should you store and manage sensitive information?
Hard
130.Scenario 5: Deployment failed because a dependency was not created in time. How do you ensure correct management?Medium
130.Scenario 5: Deployment failed because a dependency was not created in time. How do you ensure correct management?
Medium
131.Scenario 6: Modifying a parameter causes Terraform to plan a delete/recreate. How do you avoid downtime?Hard
131.Scenario 6: Modifying a parameter causes Terraform to plan a delete/recreate. How do you avoid downtime?
Hard
132.Scenario 7: Each team needs to create an S3 bucket with the same policies. How do you avoid repeating code?Medium
132.Scenario 7: Each team needs to create an S3 bucket with the same policies. How do you avoid repeating code?
Medium
133.Scenario 8: How should you set up a CI/CD pipeline for Terraform?Hard
133.Scenario 8: How should you set up a CI/CD pipeline for Terraform?
Hard
134.Scenario 9: A Terraform state file became corrupted. How do you recover it?Hard
134.Scenario 9: A Terraform state file became corrupted. How do you recover it?
Hard
135.Scenario 10: Your terraform apply fails with an error saying a required resource doesn't exist. How do you troubleshoot?Hard
135.Scenario 10: Your terraform apply fails with an error saying a required resource doesn't exist. How do you troubleshoot?
Hard
136.Scenario 11: You need to provision infrastructure across multiple AWS regions. How would you structure your Terraform configuration?Hard
136.Scenario 11: You need to provision infrastructure across multiple AWS regions. How would you structure your Terraform configuration?
Hard
137.Scenario 12: A team member accidentally ran terraform destroy on production. How do you prevent this in the future?Hard
137.Scenario 12: A team member accidentally ran terraform destroy on production. How do you prevent this in the future?
Hard
138.Scenario 13: You need to migrate from one backend to another. What are the steps?Hard
138.Scenario 13: You need to migrate from one backend to another. What are the steps?
Hard
139.Scenario 14: Your Terraform state is out of sync with actual infrastructure. How do you fix it?Hard
139.Scenario 14: Your Terraform state is out of sync with actual infrastructure. How do you fix it?
Hard
140.Scenario 15: You need to create 10 identical EC2 instances. What's the best approach?Medium
140.Scenario 15: You need to create 10 identical EC2 instances. What's the best approach?
Medium
141.Scenario 16: A resource creation is taking too long and timing out. How do you handle this?Hard
141.Scenario 16: A resource creation is taking too long and timing out. How do you handle this?
Hard