Using Modules

Public Modules – Terraform Registry

  • Terraform registry integration into core Terraform
  • e.g.
module "consul" {
  source  = "hashicorp/consul/aws"
  version = "0.1.0"
  • terraform init downloads and caches any included modules

Private Modules

  • Supplied by Terraform Cloud or any third party registry which implements the API
  • e.g.
module "vpc" {
  source  = ""
  version = "0.9.3"

Other Options


  • count
  • for_each
  • providers—allows provider config to be passed to the child module
    • Default: module inherits all default (un-aliased) provider configurations from the parent module
  • depends_on

Publishing Modules


  • Must be in a public GitHub repo
  • Repo must be named terraform-<PROVIDER>-<NAME>
  • Must have a repo description
  • Must adhere to the standard module structure
  • Must have at least one release tag, following semantic versioning, i.e. x.y.z
    • Optionally prefixed with v

Graph View