Terraform & IaC

Modules & Reuse

Package and reuse infrastructure patterns.

35 min read intermediate 3 objectives

Status

Not started

What you will learn

  • Build modules
  • Pass inputs and outputs
  • Version modules

New to this? Start here

The basics, in plain English

If you find yourself writing the same infrastructure over and over, you can package it into a reusable building block called a module. Then you use it many times with different inputs, just like a function in programming.

Module
A reusable bundle of Terraform resources you can use again and again.
Input
A value you pass into a module to customize what it builds.
Output
A value a module hands back, like the ID of something it created.
Reuse
Using the same tested module everywhere instead of copy-pasting config.
Versioning
Pinning a module to a specific version so upgrades are deliberate.
01

DRY infrastructure

Modules encapsulate a set of resources behind inputs and outputs, so a VPC pattern can be reused across teams and pinned to versions.

Finished this topic?

Mark it done to earn 100 XP and keep your streak alive.