Introduction
Using the Delete a Module API you can quickly remove the entire module, a specific provider within the module, or even a specific version of the module depending on your needs.
Expected Outcome
Once the API call is successfully executed, the module specified should be deleted and no longer viewable in the Terraform Enterprise UI.
Prerequisites
- Terraform Enterprise version
v202106-1
(544) or later- (Older versions please refer to the Deprecation warning on the Delete a Module API docs)
Use Case
There are some circumstances where deleting a module outside of the UI is desirable. One situation would be where a module fails to upload to Terraform Enterprise correctly causing issues preventing you from deleting the module from within the Terraform Enterprise UI.
Procedure
Delete an entire private module:
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>
Delete a specific provider of a module:
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>
Delete a specific version of a provider module:
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>