Terraform is a widespread Infrastructure as Code (IaC) tool that allows developers to define cloud infrastructure using declarative configuration files. One of its most powerful features is the ability to create and use modules, which package up reusable infrastructure components. When managing multiple EC2 instances or other AWS resources, modularizing your Terraform code improves efficiency, reduces duplication, and enhances maintainability.
https://businesscompassllc.com/optimizing-ec2-instance-management-with-terraform-modules-a-step-by-step-guide/