Loading...
AwsUncategorized

Terraform Interview Questions Phase 1

1. What is Terraform?
A) Terraform is an open-source IaC tool for provisioning cloud resources.

2. Who created Terraform?
A) Terraform is developed by HashiCorp.

3. What language does Terraform use?
A) Terraform uses HCL (HashiCorp Configuration Language).

4. What is Infrastructure as Code?
A) Writing infrastructure setup as code instead of manual processes.

5. What is a Terraform Provider?
A) A plugin that lets Terraform interact with cloud platforms like AWS, Azure, GCP.

6. What is a Terraform Module?
A) A reusable set of Terraform configs.

7. What is a Terraform State file?
A) It tracks the current state of infrastructure managed by Terraform.

8. What is terraform init?
A) Initializes a Terraform project and downloads providers.

9. What is terraform plan?
A) Shows what Terraform will do before applying changes.

10. What is terraform apply?
A) Executes the changes and provisions infrastructure.

11. What is terraform destroy?
A) Deletes all resources defined in the configuration.

12. What is terraform validate?
A) Checks if the Terraform config is syntactically valid.

13. What is terraform fmt?
A) Formats Terraform code to a standard style.

14. What is a backend in Terraform?
A) Defines how and where Terraform stores state (e.g., local, S3, etc.).

15. What is remote state?
A) Storing the Terraform state file in a shared location like S3

16. What are variables in Terraform?
A) Variables allow parameterization of Terraform configs.

17. What is terraform.tfvars?
A) A file to define values for variables.

18. What are output values?
A) They return values after resource creation (e.g., IPs, URLs).

19. What is a data source in Terraform?
A) It fetches data from existing infrastructure for use in configs.

20. What are Terraform workspaces?
A) They allow managing multiple state files (e.g., dev, prod).

21. What is a resource block in Terraform?
A) It’s used to define infrastructure components.

22. How do you define dependencies?
A) Terraform automatically detects them, or use depends_on.

23. What is a lifecycle block?
A) It customizes resource behavior like create_before_destroy.

24. What is count in Terraform?
A) It is used to create multiple instances of a resource.

25. What is for_each in Terraform?
A) It creates resources based on a map or set of strings.

26. What is a local value?
A) A named expression to simplify complex values.

27. What is terraform taint?
A) Marks a resource for recreation on next apply.

28. What is terraform import?
A) Brings existing infrastructure into Terraform management.

29. What is terraform state command?
A) It inspects and modifies the Terraform state file.

30. What is the .terraform.lock.hcl file?
A) It locks provider versions for consistent deployments.

31. What is a null resource in Terraform?
A) A resource that runs provisioners without managing real infra.

32. What is a provisioner in Terraform?
A) Used to execute scripts or commands on resources.

33. When should provisioners be avoided?
A) When the same can be achieved via cloud-init or native options.

34. What is the difference between count and for_each?
A) count uses index-based iteration; for_each uses map/set keys.

35. How do you handle secrets in Terraform?
A) Using environment variables, .tfvars, or secret managers.

36. How to secure the state file?
A) Use remote backends like S3 with encryption and access control.

37. How to version lock a provider?
A) Use version argument in the provider block.

38. What is drift in Terraform?
A) When actual infrastructure differs from the state file.

39. How to avoid accidental changes in Terraform?
A) Use terraform plan, version control, and manual approvals.

40. How do you handle multiple environments in Terraform?
A) Use workspaces or separate variable files/modules.

41. How to modularize Terraform code?
A) Break code into reusable modules and keep them DRY.

42. What is the use of .terraform directory?
A) It stores provider plugins and initialization data.

43. How to debug Terraform?
A) Use TF_LOG=DEBUG for detailed logs.

44. How to upgrade Terraform?
A) Install new binary and use terraform init -upgrade.

45. Can Terraform manage resources across multiple providers?
A) Yes, by configuring multiple providers in the same config.

46. What is state locking in Terraform?
A) Prevents concurrent changes to state with a lock mechanism.

47. What is a backend configuration block?
A) It configures the backend where state is stored.

48. Difference: Terraform vs CloudFormation?
A) Terraform is multi-cloud & CloudFormation is AWS-only.

49. What happens when you delete the state file?
A) Terraform loses track of resources and may recreate them.

50. Can you use Terraform with GitHub Actions?
A) Yes, to automate deployments via CI/CD.

Leave a Reply

Your email address will not be published. Required fields are marked *