
Integrating Modules in Terraform Configuration
Terraform allows the reuse of resource definition collections through modules. To integrate a module, first identify the desired module and add a module block to your configuration, configuring the source argument to specify where Terraform should obtain the child module's configuration files.
Modules can be hosted on public or private Terraform registries, Git repositories, object storage services, and the local file system. Depending on the module source, you can configure how Terraform installs the module. When using modules from a registry, you can add the version argument to specify a version constraint.
For modules hosted on GitHub, BitBucket, or other Git repositories, Terraform uses the default branch referenced by HEAD. You can add the ref query parameter to the source argument location to reference values supported by the git checkout command. When retrieving module sources from large repositories, a shallow clone can reduce download time.
Module authors expose inputs that can be configured as arguments in the module block, allowing customization of the module's behavior without modifying its source code. Terraform parallelizes module resource creation, but some modules may depend on outputs from upstream resources. Dependencies can be explicitly configured using the depends_on argument.
By default, Terraform applies the default provider based on the module resource type, but multiple provider configurations can be created for specific modules. A provider argument can be added to the module block to apply an alternate provider configuration. The resources defined in a module form a self-contained group of resources.