Infrastructure as code
Terraform
Terraform is the most requested infrastructure-as-code tool in Bangalore DevOps job descriptions. If you already know CloudFormation, EKS or GitOps, the concepts will feel familiar; what interviews test is fluency in HCL, a real understanding of state, the module and environment patterns teams use, and the team workflow around plans and applies. This topic is written to take you from zero to interview-ready, ending with a worked EKS platform example you can build as a portfolio project.
After this topic you can
- Write Terraform with variables, modules and remote state
- Review plans safely and handle drift and imports
- Run Terraform for a team through CI with locking
Lessons
-
1Infrastructure as code and how Terraform works
- What Terraform is
- The core workflow
- How plan works internally
- Terraform vs alternatives
- Licence and OpenTofu
-
2HCL: the language
- Blocks, arguments and types
- Variables, locals and outputs
- Expressions and functions
- Data sources
- Dynamic blocks
-
3Providers and version management
- Declaring and pinning
- Configuring the AWS provider
-
4State in depth
- What state contains and why it matters
- Remote backends
- Locking in practice
- State commands
- Refactoring without destroying: moved and removed
- Importing existing infrastructure
- Drift
- Recovering from state problems
-
5Meta-arguments and lifecycle
- count vs for_each
- lifecycle
- depends_on
-
6Modules
- What a module is
- Module design best practices
-
7Structuring environments and repositories
- Workspaces vs separate directories
- Splitting state into stacks
- Terragrunt
-
8Team workflow, CI/CD and policy
- A pull-request workflow
- GitHub Actions with OIDC (no static keys)
- Least privilege for Terraform
- 9Secrets and security in Terraform
- 10Worked example: an EKS platform with Terraform
- 11Troubleshooting Terraform
-
12Interview questions and model answers
- "What is Terraform state and why is it important?"
- "How do you manage state for a team on AWS?"
- "count vs for_each?"
- "Someone changed a security group in the console. What happens and what do you do?"
- "How do you bring existing resources under Terraform?"
- "A plan unexpectedly wants to replace the production RDS instance. What do you do?"
- "Workspaces or separate directories for environments?"
- "How do you handle secrets in Terraform?"
- "Do you have Terraform experience?" (an honest answer when it isn't from production)
- "CloudFormation vs Terraform?"