Phase1 Cloud Iac

Terraform Modules

Introduction

Modules are Terraform's way of organizing and reusing code. A module is just a directory containing .tf files that can be called from other Terraform code with different inputs. Think of modules like functions: they take inputs (variables), do something (create resources), and optionally return outputs.

Why This Matters

Without modules, Terraform code becomes a giant flat file that's hard to maintain. With modules, you can: - Create a "VPC module" that you reuse across environments - Use community modules from the Terraform Registry - Separate concerns: networking team maintains the VPC module, ML team uses it In MLOps, you might have modules for: - EKS cluster setup (networking, node groups, add-ons) - MLflow deployment (database, S3 bucket, ECS service) - Standard training job infrastructure Modules also make your infrastructure self-documenting: "This environment uses the vpc module version 2.1 with these inputs."

Tasks

Hint: registry.terraform.io/modules/terraform-aws-modules/vpc/aws

Check Understanding

AI Assistant

Ask questions about this topic. The assistant has context about what you're learning.