Terraform Interview Questions and Answers
Freshers / Beginner level questions & answers
Ques 1. What is Terraform?
Terraform is an open-source infrastructure as code (IaC) tool used for building, changing, and versioning infrastructure efficiently.
Ques 2. What is a Terraform module?
A Terraform module is a reusable and self-contained collection of Terraform configurations used to define and provision a particular piece of infrastructure.
Ques 3. What is the purpose of 'terraform init'?
'terraform init' initializes a Terraform working directory, downloading necessary plugins and setting up the backend for storing the Terraform state.
Ques 4. What is a Terraform provider?
A Terraform provider is a plugin that enables Terraform to interact with a specific cloud, infrastructure, or service provider, allowing resource creation and management.
Ques 5. What is remote backend in Terraform?
A remote backend in Terraform is a centralized location where Terraform stores its state file. It allows collaboration among team members and supports features like locking and state versioning.
Ques 6. What is Terraform's HCL?
HCL (HashiCorp Configuration Language) is the language used to write configuration files in Terraform. It is designed to be easy to read and write for both humans and machines.
Ques 7. What is Terraform's interpolation syntax?
Interpolation syntax is used in Terraform to insert values into strings. Examples include '${}' for variable interpolation and '${resource.type.name}' for referencing resource attributes.
Ques 8. What are Terraform workspaces used for?
Terraform workspaces allow you to manage multiple instances of the same infrastructure in a single configuration. Each workspace has its own state file, making it useful for environment separation.
Ques 9. Explain the purpose of 'terraform refresh'.
'terraform refresh' is used to reconcile the Terraform state with the real-world infrastructure. It updates the state file with the current state of the resources.
Ques 10. Explain the purpose of 'terraform import'.
'terraform import' is used to import existing infrastructure into Terraform. It associates an existing resource with a Terraform resource configuration.
Ques 11. What is the purpose of the 'depends_on' attribute in Terraform?
The 'depends_on' attribute in Terraform is used to explicitly specify the order in which resources should be created. It creates a dependency relationship between resources.
Ques 12. What is 'terraform console' used for?
'terraform console' provides an interactive command-line interface for evaluating expressions and interpolations in the context of a Terraform configuration.
Ques 13. How do you manage different environments (dev, prod) in Terraform?
Terraform supports workspaces and variable files to manage different environments. Separate configuration files or folders can be used for each environment.
Ques 14. What is the purpose of 'terraform taint'?
'terraform taint' marks a resource instance as tainted, indicating that it should be destroyed and recreated on the next 'terraform apply'.
Most helpful rated by users: