github.com/loicalbertin/terraform@v0.6.15-0.20170626182346-8e2583055467/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  Module configuration looks like the following:
    23  
    24  ```hcl
    25  module "consul" {
    26    source  = "github.com/hashicorp/consul/terraform/aws"
    27    servers = 5
    28  }
    29  ```
    30  
    31  ## Description
    32  
    33  The `module` block configures a module and tells Terraform to build
    34  its resources. Multiple module blocks may be used to configure and use
    35  multiple modules.
    36  
    37  The NAME of the module is logical: it is used only to reference the
    38  module in other places in the configuration. It has no effect on the
    39  source of the module. Therefore, you may name modules whatever you'd like.
    40  
    41  Within the block (the `{ }`) is configuration for the module.
    42  The only required key is `source`, which tells Terraform where this module
    43  can be downloaded from. Valid source values are covered in more detail
    44  in the
    45  [module section](/docs/modules/index.html).
    46  
    47  Other configuration within the module are dependent on the module itself.
    48  Module configuration maps directly to
    49  [variables](/docs/configuration/variables.html) within the module, so
    50  parameters can have any of the data types that variables support, including
    51  lists and maps.
    52  
    53  ## Syntax
    54  
    55  The full syntax is:
    56  
    57  ```text
    58  module NAME {
    59    source = SOURCE_URL
    60  
    61    CONFIG ...
    62  }
    63  ```
    64  
    65  where `CONFIG` is:
    66  
    67  ```text
    68  KEY = VALUE
    69  ```