Skip to main content
The wrapper module pattern builds on top of existing community modules, enabling you to enforce organizational standards while reusing battle-tested code. This approach reduces maintenance overhead, maintains upstream compatibility, and ensures consistency across environments.

Why Use Wrapper Modules?

  • Consistency
    Enforce company-wide naming conventions, tag policies, and resource configurations through standardized inputs.
  • Scoped Customization
    Override only the settings you need, leaving the underlying community module intact for easier upstream upgrades.
  • Maintainability
    Minimize drift from official releases by wrapping instead of forking—updating to new versions becomes straightforward.

Common Use Cases

Implementation Example

  1. Create your wrapper module directory:
    modules/my-wrapper/
  2. In modules/my-wrapper/main.tf, call the community module and map your inputs:
  1. Declare only the variables your team needs in variables.tf:
By exposing only selected inputs, you maintain a clear contract for your internal teams while still benefitting from community-driven improvements.
  1. In your root Terraform or Terragrunt configuration, invoke modules/my-wrapper instead of the community module directly.

Choosing Between Community, Custom, and Wrapper Modules

When to Use What

  • Community Modules: Go-to for rapid prototyping or teams with minimal customization needs.
  • Custom Modules: Best for specialized architectures requiring bespoke resource definitions.
  • Wrapper Modules: Ideal for enforcing organizational governance on top of community best practices.
Avoid forking community modules unless you require deep structural changes. Wrapping keeps you in sync with upstream fixes and feature releases.

References

Watch Video