Terraform

When should you use a module instead of inline resources?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

  • You need to reuse infrastructure patterns across environments, teams, or regions without copy-paste.

  • You want to codify best practices (naming, tagging, security controls) behind a stable interface.

  • You need to version and promote infrastructure changes using semantic releases and CI pipelines.

  • You want to limit blast radius by updating one module and rolling it out gradually.