12. Modules
Last updated
Modules are containers for multiple resources that are used together. A module consists of a collection of .tf and/or .tf.json files kept together in a directory
Modules are main way to package and reuse resource configurations with terraform
Input variables are passed in via module block
Default module containing all .tf files in main working directory
A sepearte external module referred to from a .tf file
module "web-app" {
source = "../web-app"
}via HTTPS
via SSH
Generic i.e source = "git::ssh//username@example.com/storage.git"
Bitbucket
Generic Git
HTTP URLs
S3 buckets
Raise abstraction level from base resource types
Group resources in a logical fashion
Exposes input variables to allow necessary customization + composition
Provide useful defaults
Returns outputs to make further integrations possible
Last updated
module "web-app" {
source = "hashicorp/consul/aws"
version = "0.1.0"
}