Movatterモバイル変換


[0]ホーム

URL:


HashiConf 2025Don't miss the live stream of HashiConf Day 2 happening now View live stream

You are viewing documentation for version v1.10.x.View latest version.

Hands-on: Try theReuse Configuration with Modules tutorials.

Modules are containers for multiple resources that are used together. A moduleconsists of a collection of.tf and/or.tf.json files kept together in adirectory.

Modules are the main way to package and reuse resource configurations withTerraform.

The Root Module

Every Terraform configuration has at least one module, known as itsroot module, which consists of the resources defined in the.tf files inthe main working directory.

Child Modules

A Terraform module (usually the root module of a configuration) cancall othermodules to include their resources into the configuration. A module that hasbeen called by another module is often referred to as achild module.

Child modules can be called multiple times within the same configuration, andmultiple configurations can use the same child module.

Published Modules

In addition to modules from the local filesystem, Terraform can load modulesfrom a public or private registry. This makes it possible to publish modules forothers to use, and to use modules that others have published.

TheTerraform Registry hosts abroad collection of publicly available Terraform modules for configuring manykinds of common infrastructure. These modules are free to use, and Terraform candownload them automatically if you specify the appropriate source and version ina module call block.

Also, members of your organization might produce modules specifically craftedfor your own infrastructure needs.HCP Terraform andTerraform Enterprise both include a privatemodule registry for sharing modules internally within your organization.

Using Modules

  • Module Blocks documents the syntax forcalling a child module from a parent module, including meta-arguments likefor_each.

  • Module Sources documents what kinds of paths,addresses, and URIs can be used in thesource argument of a module block.

  • The Meta-Arguments section documents special arguments that can be used withevery module, includingproviders,depends_on,count,andfor_each.

Developing Modules

For information about developing reusable modules, seeModule Development.

Edit this page on GitHub

[8]ページ先頭

©2009-2025 Movatter.jp