Introduction
Using the Delete a Module API, you can quickly remove an entire module, a specific provider within a module, or a specific version of a module.
Expected Outcome
Once the API call is successfully executed, the specified module will be deleted and no longer viewable in the Terraform Enterprise UI.
Prerequisites
- You must use Terraform Enterprise version
v202106-1(544) or later. - For older versions, refer to the deprecation warning in the API documentation.
Use Case
In some circumstances, deleting a module outside of the UI is necessary. For example, a module may fail to upload to Terraform Enterprise correctly, causing issues that prevent you from deleting it from within the UI.
Procedure
This section provides three different API calls depending on the scope of the deletion.
Option 1: Delete an entire private module
To delete an entire private module, including all of its providers and versions, run the following command.
$ curl -k --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://$TFE_URL/api/v2/organizations/<ORG_NAME>/registry-modules/private/<ORG_NAME>/<MODULE_NAME>
Option 2: Delete a specific provider from a module
To delete a specific provider from a module, run the following command.
$ curl -k --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://$TFE_URL/api/v2/organizations/<ORG_NAME>/registry-modules/private/<ORG_NAME>/<MODULE_NAME>/<PROVIDER_NAME>
Option 3: Delete a specific version of a module provider
To delete a specific version of a module's provider, run the following command.
$ curl -k --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://$TFE_URL/api/v2/organizations/<ORG_NAME>/registry-modules/private/<ORG_NAME>/<MODULE_NAME>/<PROVIDER_NAME>/<VERSION>
Additional Information
- For more information, consult the Delete a module API documentation.