backend / iac / README.md

Terraform

1 min read index source

Terraform

Terraform is an Infrastructure as Code (IaC) tool for building, changing, and versioning infrastructure safely and efficiently.

Key Concepts

Core Components

  • Provider: Plugin that interacts with cloud providers
  • Resource: Infrastructure objects (servers, databases, etc.)
  • Data Source: Read-only information about existing resources
  • Module: Reusable configuration packages
  • State: Terraform’s knowledge of managed resources

Workflow

  1. Write: Define infrastructure in HCL
  2. Plan: Preview changes before applying
  3. Apply: Create or modify infrastructure
  4. Destroy: Remove infrastructure when no longer needed

State Management

  • Local State: Stored in local files
  • Remote State: Stored in remote backends (S3, Azure Storage, etc.)
  • State Locking: Prevents concurrent modifications
  • State Backend: Configuration for state storage

Common Interview Questions

  1. What is Infrastructure as Code and its benefits?
  2. Explain the difference between Terraform and CloudFormation
  3. How does Terraform state management work?
  4. What are Terraform providers and how do they work?
  5. Explain Terraform modules and their benefits
  6. How to handle sensitive data in Terraform?
  7. What is Terraform workspace and when to use it?
  8. How to implement Terraform best practices?
  9. Explain Terraform data sources vs resources
  10. How to handle Terraform state conflicts?
  11. What are Terraform variables and their types?
  12. How to implement Terraform remote state?
  13. Explain Terraform destroy and its implications
  14. How to handle Terraform version constraints?