You are on page 1of 6

www.terraform.

io
/docs/registry/modules/use.html

Finding and Using Modules from the Terraform


Registry - Terraform by HashiCorp
3-4 minutes

The Terraform Registry makes it simple to


find and use modules.

Every page on the registry has a search field for finding


modules. Enter any type of
module you're looking for (examples: "vault",
"vpc", "database") and resulting modules will
be listed. The search query
will look at module name, provider, and description to match
your search
terms. On the results page, filters can be used further refine search results.

By default, only verified modules


are shown in search results. Verified modules are
reviewed by HashiCorp to
ensure stability and compatibility. By using the filters, you can
view unverified
modules as well.

»
Using Modules
The Terraform Registry is integrated directly into Terraform, so a Terraform
configuration
can refer to any module published in the registry. The syntax for
specifying a registry
module is <NAMESPACE>/<NAME>/<PROVIDER>. For example:
hashicorp/consul/aws.

When viewing a module on the registry on a tablet or desktop, usage instructions


are
shown on the right side.
You can copy and paste this to get started with any module.
Some modules
have required inputs you must set before being able to use the module.

module "consul" {

source = "hashicorp/consul/aws"

version = "0.1.0"

The terraform init command will download and cache any modules referenced by
a
configuration.

»
Private Registry Module Sources

You can also use modules from a private registry, like the one provided by
Terraform
Cloud. Private registry modules have source strings of the form
<HOSTNAME>/<NAMESPACE>/<NAME>/<PROVIDER>. This is the same format as the
public
registry, but with an added hostname prefix.

module "vpc" {

source = "app.terraform.io/example_corp/vpc/aws"

version = "0.9.3"

Depending on the registry you're using, you might also need to configure
credentials to
access modules. See your registry's documentation for details.
Terraform Cloud's private
registry is documented here.

Private registry module sources are supported in Terraform v0.11.0 and


newer.

»
Module Versions
Each module in the registry is versioned. These versions syntactically must
follow
semantic versioning. In addition to pure syntax,
we encourage all modules to follow the full
guidelines of semantic versioning.

Terraform since version 0.11 will resolve any provided


module version constraints and
using them is highly recommended to avoid pulling in breaking changes.

Terraform versions after 0.10.6 but before 0.11 have partial support for the registry
protocol, but always download the latest version instead of honoring version
constraints.
www.terraform.io
/docs/registry/modules/publish.html

Terraform Registry - Publishing Modules - Terraform


by HashiCorp
4-5 minutes

Anyone can publish and share modules on the Terraform Registry.

Published modules support versioning, automatically generate documentation,


allow
browsing version histories, show examples and READMEs, and more. We
recommend
publishing reusable modules to a registry.

Public modules are managed via Git and GitHub. Publishing a module takes only
a few
minutes. Once a module is published, you can release a new version of
a module by
simply pushing a properly formed Git tag.

The registry extracts information about the module from the module's source.
The module
name, provider, documentation, inputs/outputs, and dependencies are
all parsed and
available via the UI or API, as well as the same information for
any submodules or
examples in the module's source repository.

»
Requirements
The list below contains all the requirements for publishing a module:

GitHub. The module must be on GitHub and must be a public repo.


This is only a
requirement for the public registry.
If you're using a private registry, you may ignore
this requirement.

Named terraform-<PROVIDER>-<NAME>. Module repositories must use this


three-
part name format, where <NAME> reflects the type of infrastructure the
module
manages and <PROVIDER> is the main provider where it creates that
infrastructure.
The <NAME> segment can contain additional hyphens. Examples:
terraform-
google-vault or terraform-aws-ec2-instance.

Repository description. The GitHub repository description is used


to populate the
short description of the module. This should be a simple
one sentence description of
the module.

Standard module structure. The module must adhere to the


standard module
structure.
This allows the registry to inspect your module and generate
documentation,
track resource usage, parse submodules and examples, and more.

x.y.z tags for releases. The registry uses tags to identify module
versions.
Release tag names must be a semantic version,
which can optionally be prefixed
with a v. For example, v1.0.4 and 0.9.2.
To publish a module initially, at least one
release tag must be present. Tags
that don't look like version numbers are ignored.

»
Publishing a Public Module
With the requirements met, you can publish a public module by going to
the Terraform
Registry and clicking the
"Upload" link in the top navigation.

If you're not signed in, this will ask you to connect with GitHub. We only
ask for access to
public repositories, since the public registry may only
publish public modules. We require
access to hooks so we can register a webhook
with your repository. We require access to
your email address so that we can
email you alerts about your module. We will not spam
you.

The upload page will list your available repositories, filtered to those that
match the
naming convention described above. This is shown in
the screenshot below. Select the
repository of the module you want to add and
click "Publish Module."

In a few seconds, your module will be created.

»
Releasing New Versions
The Terraform Registry uses tags to detect releases.

Tag names must be a valid semantic version, optionally


prefixed with a v. Example of valid
tags are: v1.0.1 and 0.9.4. To publish
a new module, you must already have at least
one tag created.
To release a new version, create and push a new tag with the proper format.
The webhook
will notify the registry of the new version and it will appear
on the registry usually in less
than a minute.

If your version doesn't appear properly, you may force a sync with GitHub
by viewing your
module on the registry and clicking "Resync Module"
under the "Manage Module"
dropdown. This process may take a few minutes.
Please only do this if you do not see the
version appear, since it will
cause the registry to resync all versions of your module.
www.terraform.io
/docs/registry/modules/verified.html

Terraform Registry - Verified Modules - Terraform by


HashiCorp
1-2 minutes

Verified modules are reviewed by HashiCorp and actively maintained by contributors to


stay up-to-date and compatible with both Terraform and their respective providers.

The verified badge appears next to modules that are published by a verified source.

Verified modules are expected to be actively maintained by HashiCorp partners.


The
verified badge isn’t indicative of flexibility or feature support; very
simple modules can be
verified just because they're great examples of modules.
Likewise, an unverified module
could be extremely high quality and actively
maintained. An unverified module shouldn't
be assumed to be poor quality, it
only means it hasn't been created by a HashiCorp
partner.

When using registry modules, there is no


difference between a verified and unverified
module; they are used the same
way.

You might also like