Terraform
1. What is Terraform?
o Terraform is an open-source infrastructure as code (IaC) tool that allows you to
define and provision cloud infrastructure using a high-level configuration language.
2. What is a Terraform provider?
o A Terraform provider is a plugin that allows Terraform to interact with APIs of cloud
platforms like AWS, Azure, and GCP.
3. How do you define resources in Terraform?
o Resources are defined in .tf files using the resource block, specifying the resource
type and configuration.
4. What is a Terraform module?
o A module in Terraform is a container for multiple resources that are used together.
Modules are used to organize and reuse code.
5. How do you initialize a Terraform project?
o Run terraform init to download the necessary providers and set up the environment
for your Terraform project.
6. What is Terraform state?
o Terraform state is a file that keeps track of the infrastructure managed by Terraform,
mapping real-world resources to your configuration.
7. How do you apply a Terraform configuration?
o Use terraform apply to create or update resources as defined in your Terraform
configuration.
8. What is Terraform plan?
o terraform plan is a command that generates an execution plan, showing what
actions Terraform will take to reach the desired state.
9. How do you destroy resources managed by Terraform?
o Use terraform destroy to delete all resources managed by your Terraform project.
10. What is Terraform backend?
o A backend in Terraform defines where and how Terraform state is stored and how
operations are executed.
11. How do you manage sensitive data in Terraform?
o Sensitive data can be managed using environment variables, encrypted backends, or
third-party tools like HashiCorp Vault.
12. What is a data source in Terraform?
o A data source allows you to fetch information from outside Terraform and use it in
your configuration.
13. How do you create reusable Terraform modules?
o Define a module by organizing code in a directory with input variables, output
values, and resource definitions. Reference the module in other configurations using
the module block.
14. What is the purpose of terraform fmt?
o terraform fmt formats your Terraform configuration files to follow a consistent style.
15. How do you manage multiple environments in Terraform?
o Use workspaces, separate state files, or separate configurations to manage different
environments (e.g., dev, staging, prod).
16. What is Terraform Cloud?
o Terraform Cloud is a managed service offering collaboration, governance, and
automation capabilities for Terraform users.
17. What are Terraform workspaces?
o Workspaces allow you to manage multiple instances of your infrastructure within a
single configuration by maintaining separate state files.
18. How do you import existing infrastructure into Terraform?
o Use terraform import to bring existing resources into Terraform management by
linking them to your Terraform state.
19. What is the difference between terraform apply and terraform taint?
o terraform apply creates or updates resources as defined, while terraform taint marks
a resource for destruction and recreation in the next apply.
20. How do you upgrade Terraform providers?
o Update the provider version in your configuration and run terraform init -upgrade to
upgrade to the specified version.