Introduction
This article provides a guide on how to delete an "official" version of Terraform from your Terraform Enterprise (TFE) instance. Certain situations, such as using an older version of TFE that does not have a desired Terraform version bundled, may require you to add Terraform versions manually. This manual process can sometimes lead to misconfigurations that require the deletion of the custom Terraform version.
Expected Outcome
By the end of this guide, you will be able to delete a manually added "official" version of Terraform that is not being used by any workspace.
Prerequisites
- A running Terraform Enterprise instance.
- Administrative access to the TFE instance.
- The version of Terraform to be deleted is not in use by any workspace.
- The manually added Terraform version had the attribute
"official": truein the payload at the time of upload.
Procedure
To delete the Terraform version, you must first update its official attribute to false before using the delete API endpoint.
-
Update the Terraform version to be unofficial.
Create a file named
payload.jsonwith the following content.{ "data": { "type": "terraform-versions", "attributes": { "official": false } } }Next, use the Update a Terraform version API to change the attribute from
"official": trueto"official": false.$ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @payload.json \ https://assured-gnu.tf-support.hashicorpdemo.com/api/v2/admin/terraform-versions/tool-Ft4NLfL2QApeSFHX
-
Delete the Terraform version.
Run the Delete a Terraform version API call to delete the Terraform version.
$ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request DELETE \ https://assured-gnu.tf-support.hashicorpdemo.com/api/v2/admin/terraform-versions/tool-Ft4NLfL2QApeSFHX
Important Considerations
Official bundled versions of Terraform should not be removed or replaced with custom versions that are labeled as official. If this is done, the custom Terraform version will be replaced by the official bundled Terraform version the next time you update the Terraform Enterprise application.