terraform/website/docs/configuration/modules.html.md

70 lines
1.8 KiB
Markdown
Raw Normal View History

2014-09-26 23:23:38 +02:00
---
layout: "docs"
page_title: "Configuring Modules"
sidebar_current: "docs-config-modules"
2014-10-22 05:21:56 +02:00
description: |-
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.
2014-09-26 23:23:38 +02:00
---
# Module Configuration
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](/docs/modules/index.html).
This page assumes you're familiar with the
[configuration syntax](/docs/configuration/syntax.html)
already.
## Example
Module configuration looks like the following:
```hcl
2014-09-26 23:23:38 +02:00
module "consul" {
source = "github.com/hashicorp/consul/terraform/aws"
servers = 5
2014-09-26 23:23:38 +02:00
}
```
## Description
The `module` block configures a module and tells Terraform to build
its resources. Multiple module blocks may be used to configure and use
multiple modules.
The NAME of the module is logical: it is used only to reference the
module in other places in the configuration. It has no effect on the
source of the module. Therefore, you may name modules whatever you'd like.
Within the block (the `{ }`) is configuration for the module.
The only required key is `source`, which tells Terraform where this module
can be downloaded from. Valid source values are covered in more detail
in the
[module section](/docs/modules/index.html).
Other configuration within the module are dependent on the module itself.
2016-07-12 00:37:51 +02:00
Module configuration maps directly to
[variables](/docs/configuration/variables.html) within the module, so
parameters can have any of the data types that variables support, including
lists and maps.
2014-09-26 23:23:38 +02:00
## Syntax
The full syntax is:
```text
2014-09-26 23:23:38 +02:00
module NAME {
source = SOURCE_URL
2014-09-26 23:23:38 +02:00
CONFIG ...
2014-09-26 23:23:38 +02:00
}
```
where `CONFIG` is:
```text
2014-09-26 23:23:38 +02:00
KEY = VALUE
```