Opscraft
Infrastructure as code

Terraform

12 lessons · 49 min · 3 tests ·

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.

Stage 2 · Core tools

Know these first

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

  1. 1Infrastructure as code and how Terraform works 7 min read
    • What Terraform is
    • The core workflow
    • How plan works internally
    • Terraform vs alternatives
    • Licence and OpenTofu
  2. 2HCL: the language 4 min read
    • Blocks, arguments and types
    • Variables, locals and outputs
    • Expressions and functions
    • Data sources
    • Dynamic blocks
  3. 3Providers and version management 3 min read
    • Declaring and pinning
    • Configuring the AWS provider
  4. 4State in depth 8 min read
    • 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
  5. 5Meta-arguments and lifecycle 4 min read
    • count vs for_each
    • lifecycle
    • depends_on
  6. 6Modules 3 min read
    • What a module is
    • Module design best practices
  7. 7Structuring environments and repositories 3 min read
    • Workspaces vs separate directories
    • Splitting state into stacks
    • Terragrunt
  8. 8Team workflow, CI/CD and policy 3 min read
    • A pull-request workflow
    • GitHub Actions with OIDC (no static keys)
    • Least privilege for Terraform
  9. 9Secrets and security in Terraform 3 min read
  10. 10Worked example: an EKS platform with Terraform 3 min read
  11. 11Troubleshooting Terraform 3 min read
  12. 12Interview questions and model answers 5 min read
    • "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?"