How do Terraform modules work and what makes a good module?

Medium Topic: Terraform May 24, 2026

A Terraform module is a reusable group of resource configurations. Every directory with .tf files is a module. You call modules from a root module to avoid repeating code.

What makes a good module:

  • Single responsibility: One module for VPC, another for EKS, another for RDS.
  • Parameterized: Accept variables to customize behavior per environment.
  • Versioned: Pin module versions in the source attribute.
  • Outputs: Expose useful outputs (VPC ID, subnet IDs) for other modules to consume.
← Previous What does terraform plan do and why should... Next → What is Terraform state drift and how do...

Practice Similar Questions

Back to Terraform Topics