Introduction
This article provides a guide on how to delete an "official" version of Terraform from your Terraform Enterprise (TFE) instance. Some situations require the manual addition of Terraform versions to a TFE instance, such as using an older version of TFE that doesn't have the desired Terraform version bundled by default. Due to the manual nature of this process, misconfigurations are possible, which may require the deletion of the Terraform version.
Expected Outcome
By the end of this guide, you should be able to delete an "official" version of Terraform that is not being used by any workspace.
Prerequisites
- Terraform Enterprise instance
- Admin access to the TFE instance
- The version of Terraform to be deleted should not be in use by any workspace
- The manually added Terraform version had the attribute
"official": true,
in the payload at the time of upload
Procedure
-
Use the Update a Terraform version API to change the attribute from
"official": true
to"official": false
using the following payload data andcurl
call.
payload.json
{
"data": {
"type": "terraform-versions",
"attributes": {
"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
-
Run the Delete a Terraform version API call to delete the Terraform version in question.
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
- Once the Terraform version in question is deleted you are okay to proceed as you see fit.
Note:
Please note that 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 Terraform version the next time the Terraform Enterprise app is updated.