Week 14: Terraform — Infrastructure as Code at Scale

Theme: Write modular, reusable Terraform for cloud infrastructure.

Learning Objectives

  1. Write Terraform modules with inputs, outputs, and version constraints
  2. Manage Terraform state with remote backends (S3 + DynamoDB)
  3. Implement Terraform workspaces for dev/staging/prod environments
  4. Use Terragrunt for DRY infrastructure configuration

Reading Materials

Finger Exercises (choose 2)

  1. Write a Terraform module for an EKS cluster: VPC, subnets, EKS control plane, node group. Use remote state with S3 backend.
  2. Use Terraform to create an ElastiCache Redis cluster. Output the endpoint. Import it into the K8s app as an environment variable.
  3. Set up a remote state S3 bucket with DynamoDB state locking.

Project

Write Terraform modules for the Phase 1-3 stack's cloud infrastructure:

Create 3 workspaces: dev, staging, prod with different instance sizes. Use Terragrunt to avoid repeating configuration across environments. Integrate with the Kubernetes provider to manage K8s resources within Terraform (optional). Store state in S3 (dev) and S3 + DynamoDB locking (staging, prod).

Time Budget

ActivityTime
Reading1.5 hrs
Finger exercises2 hrs
Project2.5 hrs
Total6 hrs