Problem
When you attempt to publish a module to the private module registry in HCP Terraform or Terraform Enterprise, you receive the following error message.
Error publishing module This module has already been published. Click here to view this module.
If you select the link in the error message, the status message indefinitely states, “Waiting for module to become ready”.
Cause
On rare occasions, networking issues may occur during module publication that cause the module version to become corrupted. When this happens, the application behaves as though the module is published, but the module is damaged and inaccessible.
Solution
To resolve this issue, you must delete the corrupted private module version using the API. After deleting the corrupted module, you can republish it through the UI or API.
- Identify the
ORGANIZATION_NAME,MODULE_NAME,PROVIDER, andVERSIONfor the corrupted module. -
Use the Delete a specific module version API endpoint to remove the corrupted module version. Replace the placeholder values with your module's information in the following command.
$ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://app.terraform.io/api/v2/organizations/ORGANIZATION_NAME/registry-modules/private/ORGANIZATION_NAME/MODULE_NAME/PROVIDER/versions/VERSION
After the API call successfully deletes the module version, you can publish it again.
Additional Information
Please see the module deletion API documentation for full details on how to perform an API deletion.