github.com/pdecat/terraform@v0.11.9-beta1/website/docs/configuration/modules.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Configuring Modules"
     4  sidebar_current: "docs-config-modules"
     5  description: |-
     6    Modules are used in Terraform to modularize and encapsulate groups of resources in your infrastructure. For more information on modules, see the dedicated modules section.
     7  ---
     8  
     9  # Module Configuration
    10  
    11  Modules are used in Terraform to modularize and encapsulate groups of
    12  resources in your infrastructure. For more information on modules, see
    13  the dedicated
    14  [modules section](/docs/modules/index.html).
    15  
    16  This page assumes you're familiar with the
    17  [configuration syntax](/docs/configuration/syntax.html)
    18  already.
    19  
    20  ## Example
    21  
    22  ```hcl
    23  module "consul" {
    24    source  = "hashicorp/consul/aws"
    25    servers = 5
    26  }
    27  ```
    28  
    29  ## Description
    30  
    31  A `module` block instructs Terraform to create an instance of a module,
    32  and in turn to instantiate any resources defined within it.
    33  
    34  The name given in the block header is used to reference the particular module
    35  instance from expressions within the calling module, and to refer to the
    36  module on the command line. It has no meaning outside of a particular
    37  Terraform configuration.
    38  
    39  Within the block body is the configuration for the module. All attributes
    40  within the block must correspond to [variables](/docs/configuration/variables.html)
    41  within the module, with the exception of the following which Terraform
    42  treats as special:
    43  
    44  * `source` - (Required) A [module source](/docs/modules/sources.html) string
    45    specifying the location of the child module source code.
    46  
    47  * `version` - (Optional) A [version constraint](/docs/modules/usage.html#module-versions)
    48    string that specifies which versions of the referenced module are acceptable.
    49    The newest version matching the constraint will be used. `version` is supported
    50    only for modules retrieved from module registries.
    51  
    52  * `providers` - (Optional) A map whose keys are provider configuration names
    53    that are expected by child module and whose values are corresponding
    54    provider names in the calling module. This allows
    55    [provider configurations to be passed explicitly to child modules](/docs/modules/usage.html#providers-within-modules).
    56    If not specified, the child module inherits all of the default (un-aliased)
    57    provider configurations from the calling module.