Problem
When attempting to use a module from a private module registry in HCP Terraform or Terraform Enterprise, you may encounter the following error:
Module source repository has no tags. The source repository for the module "[module]" for provider "[provider]" has no tags and therefore failed to setup. Please read the documentation on creating modules.
Cause
This error occurs because modules in the private registry require Git tags that follow semantic versioning (e.g., v1.0.0) to track and serve module versions. If the underlying Version Control System (VCS) repository for the module does not have any version tags, Terraform cannot resolve a version to download and the operation fails.
Solutions
Here are two approaches to resolve this issue.
Solution 1: Add a Version Tag to the Repository
The most direct solution is to add a correctly formatted version tag to your module's VCS repository. This is the recommended first step.
- Navigate to your local clone of the module repository.
-
Create a new tag. The tag must be in a valid version format, such as
v1.0.0.$ git tag -a "v1.0.0" -m "First release"
-
Push the new tag to the remote repository.
$ git push origin v1.0.0
After pushing the tag, attempt your Terraform run again. Note that in some cases, the registry may have a cached state of the module. If this solution does not work, proceed to Solution 2.
Solution 2: Re-publish the Module
If adding a tag does not resolve the issue, you may need to delete and re-publish the module to force the registry to recognize the new version tags.
- Confirm that the module's VCS repository has correctly formatted version tags in place. If not, add them as described in Solution 1.
- Ensure that the module is not in active use in any Terraform runs.
- In the HCP Terraform or Terraform Enterprise UI, navigate to the module in the private registry and delete it using the Delete Module button.
- Re-publish the module to the private module registry. The registry will now detect the version tags from the repository.
Additional Information
For more details on module development and versioning, refer to the official Terraform documentation on creating and publishing modules.