This topic describes how to publish private modules to an organization's private registry. For instructions on adding modules from the public registry, refer to Add modules from the Terraform registry.
Hands-on: Try the Share Modules in the Private Module Registry tutorial.
When publishing modules to the private registry, the registry downloads the module source code. The registry handles downloads and controls access with HCP Terraform API tokens, so consumers do not need access to the module's source repository, even when running Terraform from the command line. The private registry uses your version control system (VCS) integrations and delegates management tasks, such as handling new version releases, to your VCS provider. The only manual tasks are adding a new module and deleting module versions.
Access to private modulesPrivate modules are only available to members of the organization that owns the private registry. In Terraform Enterprise, they are also available to organizations that you configure to share modules with that organization.
Publishing worfklowsYou can publish modules according to VCS tags or branches. Refer to Tag-based publishing considerations and Branch-based publishing considerations for more information.
Verify that you have met the following requirements before completing these instructions.
PermissionsYou must be a member of the owners team and teams with Manage private registry permissions enabled to publish and delete modules from the private registry.
VCS provider settingsThe registry automatically detects module names and versions in the repository. Your module repository must meet all of the following requirements before adding it to the registry.
Specify a prefix to filter repository Git tags when using the tag-based publishing type in a repository that contains code for multiple modules. Without a prefix, HCP Terraform and Terraform Enterprise publish new versions for all modules with valid Git tags that use semantic versioning.
For example, specifying app
as a tag prefix for the registry module instructs HCP Terraform to select only Git tags with the prefix app
in them. As a result, HCP Terrraform selects the module tagged with appv1.0.0
and publishes v1.0.0
to the registry.
Refer to Enable publishing from a single repository
ModuleBy default, HCP Terraform and Terraform Enterprise require a separate repository for each module. As a result, each module must use the following three-part naming convention:
terraform-<PROVIDER>-<NAME>
The <NAME>
segment reflects the type of infrastructure the module manages and <PROVIDER>
is the main provider where it creates the infrastructure.
The <PROVIDER>
segment must be all lowercase. The <NAME>
segment can contain additional hyphens.
Examples:
When the Publish modules to your private registry from a single repository option is enabled,you can store multiple modules in a single repository. As a result, modules do not need to follow the naming convention. Refer to the following topics for more information:
Note
This feature is currently in beta. Do not use beta functionality in production environments.
By default, HCP Terraform and Terraform Enterprise retrieve new versions of modules published to the private registry according to the repository release tag. As a result, you must store the code for each module in separate repositories. Otherwise, the registry retrieves and publishes new versions of all modules in a repository each time you create a new release tag.
If you want to use a single repository to store modules source code, you can enable the Publish modules to your private registry from a single repository option in your workspace's general settings. When this option is enabled, you can add a prefix to the version tag that the registry uses to select module sources to publish when new you create new release tags. Refer to Release tag prefixes for additional information.
After enabling this option, complete the instructions for publishing a new module.
You can publish modules using either the UI or API. Refer to Publish a Private Module from a VCS for instructions on using API. Note that you can also call the API to publish modules without a VCS repository as the source, which is not possible in the UI.
The interface for publishing modules and the registry behavior depends on how the Publish modules to your private registry from a single repository option. Refer to Enable publishing from a single repository for more information about this setting.
One module per repositoryThe Publish modules to your private registry from a single repository option is disabled by default, which requires requires each module to be stored in its own repository. Complete the following steps when this option is disabled:
Sign in to HCP Terraform or Terraform Enterprise and navigate to the organization where you want to publish a module.
Select Registry from the sidebar.
Choose Module from the Publish and drop-down menu. The Add Module page appears with a list of available repositories.
Click on a VCS connection. The screen advances to the Choose a repository step.
Select the repository containing the module you want to publish.
You can search the list by typing part or all of a repository name into the filter field. Remember that VCS providers use <NAMESPACE>/<REPO NAME>
strings to locate repositories. The namespace is an organization name for most providers, but Bitbucket Data Center, not Bitbucket Cloud, uses project keys, like INFRA
.
When prompted, choose either the Tag or Branch module publishing type.
(Optional) If this module is a no-code ready module, select the Add Module to no-code provision allowlist checkbox.
Note
No-code provisioning is available in HCP Terraform Plus and Premium editions. Refer to HCP Terraform pricing for details.
HCP Terraform displays a loading page while it imports the module versions and then takes you to the new module's details page. On the details page, you can view available versions, read documentation, and copy a usage example.
Multiple modules in a single repositoryNote
This feature is currently in beta. Do not use beta functionality in production environments.
Complete the following steps when the Publish modules to your private registry from a single repository option is enabled:
Sign in to HCP Terraform or Terraform Enterprise and navigate to the organization where you want to publish a module.
Select Registry from the sidebar.
Choose Module from the Publish and drop-down menu. The Add Module page appears with a list of available repositories.
Click on a VCS connection. The screen advances to the Configure VCS Settings step.
In the Select a VCS Repository field, choose the repository containing your modules' source code. You can search the list by typing part or all of a repository name into the filter field. VCS providers use <NAMESPACE>/<REPO NAME>
strings to locate repositories. The namespace is an organization name for most providers, but Bitbucket Data Center, not Bitbucket Cloud, uses project keys, such as INFRA
.
Enable either the Tag or Branch module publishing type. Refer to Tag-based publishing considerations and Branch-based publishing considerations for more information.
Complete the fields for your publishing type.
When Tag is enabled:
When Branch is enabled:
Click Next to advance to the Confirm selection screen.
In the Module Name field, specify a name for the module. This is the name that appears in the registry. HCP Terraform and Terraform Enterprise use the name in the module address.
In the Provider Name field, specify the name of the provider that integrates the module. HCP Terraform and Terraform Enterprise use the name in the module address.
It is optional, but if this module is a no-code ready module, enable the Add Module to no-code provision allowlist option to allow your organization members to provision resources defined by this module using the no-code workflow. Refer to Provision no-code infrastructure for more information.
Note
No-code provisioning is available in HCP Terraform Plus and Premium editions. Refer to HCP Terraform pricing for details.
HCP Terraform and Terraform Enterprise displays a loading page while it imports the module versions and then directs you to the new module's details page. On the details page, you can view available versions, read documentation, and copy a usage example.
Tag-based publishing considerationsTo enable the Tag module publishing type, your registry must use the x.y.z
format for release tags to identify module versions. Your repository must contain at least one release tag for you to publish a module. Release tag names must be a semantic version, which you can optionally prefix with a v
. For example, v1.0.4
and 0.9.2
. The registry ignores tags that do not match these formats.
To publish modules from a single repository, you should also include a tag prefix so that HCP Terraform can publish individual modules in the repository when you create new version tags. Refer to Release tag prefixes for more information.
Branch-based publishing considerationsTo enable the Branch module publishing type, you must provide the name of an existing branch in your VCS repository and provide the module with a module version. Your VCS repository does not need to contain a matching tag or release.
You can only enable testing on modules published using branch-based publishing. Refer to the test-integrated modules documentation for more information.
Module testing is disabled when the Publish modules to your private registry from a single repository option is enabled in your workspace's general settings. Refer to Enable publishing from a single repository for more information.
The process to release a new module version differs between the tag-based and branch-based publishing workflows.
Tag-based publishing workflowTo release a new version of a module in the tag-based publishing workflow, push a new release tag to its VCS repository. The registry automatically imports the new version.
Refer to Preparing a Module Repository for details about release tag requirements.
Branch-based publishing workflowTo release a new version of a module using the branch-based publishing workflow, navigate to the module overview screen, then click the Publish New Version button. Select the commit SHA that the new version will point to, and assign a new module version. You cannot re-use an existing module version.
After publishing your module, you can change between tag-based and branch-based publishing. To update your module's publish settings, navigate to the the module overview page, click the Manage Module for Organization dropdown, and then click Publish Settings.
To change from tag-based to branch-based publishing, you must configure a Module branch and create a new module version, as HCP Terraform will not automatically create one.
To change from branch-based publishing to tag-based publishing, you must create at least one tag in your VCS repository.
You can delete individual versions of a module or the entire module. Deleting a tag from your VCS repository does not automatically remove the version from the private registry. If deleting a module version would leave a module with no versions, HCP Terraform removes the entire module.
To delete a module or version:
Sign in to HCP Terraform or Terraform Enterprise and navigate to the module's details page.
If you want to delete a single version, use the Versions menu to select it.
Click Delete module.
Select an action from the menu:
terraform-aws-appserver
and terraform-azure-appserver
, the registry treats them as alternate providers of the same appserver
module.terraform-aws-appserver
and terraform-azure-appserver
.Type the module name and click Delete.
Deletion is permanent, but there are ways to restore deleted modules and module versions.
HCP Terraform does not typically allow one organization's workspaces to use private modules from a different organization. This restriction is because HCP Terraform gives Terraform temporary credentials to access modules that are only valid for that workspace's organization. Although it is possible to mix modules from multiple organizations when you run Terraform on the command line, we strongly recommend against it.
Instead, you can share modules across organizations by sharing the underlying VCS repository. Grant each organization access to the module's repository, and then add the module to each organization's registry. When you push tags to publish new module versions, both organizations update accordingly.
Terraform Enterprise administrators can configure module sharing to allow organizations to use private modules from other organizations.
Note
This feature is currently in beta. Do not use beta functionality in production environments.
You can generate and run generated tests for your module with the terraform test
command.
Before you can generate tests for a module, it must have at least one version published. Tests can only be generated once per module and are intended to be reviewed by the module's authors before being checked into version control and maintained with the rest of the module's content. If the module's configuration files exceed 128KB in total size, HCP Terraform will not be able to generate tests for that module.
You must have permission to manage registry modules and permission to manage module test generation to generate tests.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4