mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-21 02:37:43 -05:00
67 lines
2.7 KiB
Plaintext
67 lines
2.7 KiB
Plaintext
---
|
|
description: >-
|
|
Modules are containers for multiple resources that are used together in a
|
|
configuration. Find resources for using, developing, and publishing modules.
|
|
---
|
|
|
|
# Modules
|
|
|
|
_Modules_ are containers for multiple resources that are used together. A module
|
|
consists of a collection of `.tf`, `.tofu`, `.tf.json`, and/or `.tofu.json`
|
|
files that are kept together in a directory.
|
|
|
|
Modules are the main way to package and reuse resource configurations with
|
|
OpenTofu.
|
|
|
|
## The Root Module
|
|
|
|
Every OpenTofu configuration has at least one module, known as its
|
|
_root module_, which consists of the resources defined in the `.tf` or `.tofu`
|
|
files in the main working directory.
|
|
|
|
## Child Modules
|
|
|
|
An OpenTofu module (usually the root module of a configuration) can _call_ other
|
|
modules to include their resources into the configuration. A module that has
|
|
been called by another module is often referred to as a _child module._
|
|
|
|
Child modules can be called multiple times within the same configuration, and
|
|
multiple configurations can use the same child module.
|
|
|
|
## Published Modules
|
|
|
|
In addition to modules from the local filesystem, OpenTofu can load modules
|
|
from a public or private registry. This makes it possible to publish modules for
|
|
others to use, and to use modules that others have published.
|
|
|
|
The [Public OpenTofu Registry](https://github.com/opentofu/registry/tree/main/modules) hosts a
|
|
broad collection of publicly available OpenTofu modules for configuring many
|
|
kinds of common infrastructure. These modules are free to use, and OpenTofu can
|
|
download them automatically if you specify the appropriate source and version in
|
|
a module call block.
|
|
|
|
Also, members of your organization might produce modules specifically crafted
|
|
for your own infrastructure needs. [TACOS](../../intro/tacos.mdx) (TF Automation and Collaboration Software) include a private
|
|
module registry for sharing modules internally within your organization.
|
|
|
|
## Using Modules
|
|
|
|
- [Module Blocks](../../language/modules/syntax.mdx) documents the syntax for
|
|
calling a child module from a parent module, including meta-arguments like
|
|
`for_each`.
|
|
|
|
- [Module Sources](../../language/modules/sources.mdx) documents what kinds of paths,
|
|
addresses, and URIs can be used in the `source` argument of a module block.
|
|
|
|
- The Meta-Arguments section documents special arguments that can be used with
|
|
every module, including
|
|
[`providers`](../../language/meta-arguments/module-providers.mdx),
|
|
[`depends_on`](../../language/meta-arguments/depends_on.mdx),
|
|
[`count`](../../language/meta-arguments/count.mdx),
|
|
and [`for_each`](../../language/meta-arguments/for_each.mdx).
|
|
|
|
## Developing Modules
|
|
|
|
For information about developing reusable modules, see
|
|
[Module Development](../../language/modules/develop/index.mdx).
|