Practice Infrastructure as Code concepts with Terraform questions covering HCL, state management, modules, providers, and best practices.
Key topics include HCL syntax, state management (remote backends, state locking), modules and reusability, providers, resource dependencies, data sources, variables and outputs, workspaces, and lifecycle rules. Understanding terraform plan/apply workflow is essential.
Very important. Terraform is the most widely adopted IaC tool. DevOps and cloud engineering interviews frequently test your ability to write Terraform configurations, manage state safely, structure modules, and implement CI/CD pipelines for infrastructure changes.
Terraform state tracks the mapping between your configuration and real infrastructure. It is stored in a state file (terraform.tfstate). Remote backends (S3, Terraform Cloud) enable team collaboration. State locking prevents concurrent modifications. Never edit state files manually - use terraform state commands.
Modules are reusable packages of Terraform configuration. They promote DRY principles, enforce standards, and simplify complex infrastructure. Use modules for repeated patterns like VPCs, ECS services, or Lambda functions. The Terraform Registry provides community-maintained modules for common use cases.
Plan shows what changes Terraform will make without modifying infrastructure - it is a dry run. Apply executes the changes. Always review plan output before applying. In CI/CD, save the plan output and apply that exact plan to prevent unexpected changes between plan and apply.
Never store secrets in Terraform code or state in plain text. Use environment variables, AWS Secrets Manager, HashiCorp Vault, or encrypted S3 backends. Mark sensitive variables with sensitive = true. Use data sources to fetch secrets at plan time rather than hardcoding them.