Skip to content

Terraform module structure

Chris Buckley edited this page Apr 21, 2023 · 4 revisions

Modules should follow the Standard Module Structure from Terraform:

  • README.md - Documentation for the module:
    • Intro and purpose
    • terraform-docs output (use <-- {BEGIN|END}_TF_DOCS --> fences)
    • Example usage
  • versions.tf - Minimum Terraform and provider versions
  • variables.tf - Variable inputs
  • outputs.tf - Output definitions
  • data.tf - Data sources
  • locals.tf - Local variables
  • Either:
    • main.tf - All the resources in a simple module
    • *.tf - Logical clusters of discrete "features" within a module

Unlike the Terraform documentation, we don't suggest creating a base set of files even if they're empty - just omit that file until it's needed.

Clone this wiki locally