Introduction:
In Terraform Cloud and Enterprise, there are logs regarding every run that has happened in each existing workspace. Administrators may want to retain or remove these logs for security or data retention requirements.
Recommendation:
Terraform Cloud and Enterprise workspace runs logs will exist for as long as the workspace exists in the Organization.
Retention:
To retain these logs, simply keep the workspace even if it is no longer an actively used workspace.
Removal:
To remove the logs, the workspace must be deleted. A workspace can be deleted through the Terraform GUI by going to workspace settings -> destruction and deletion. From here a terraform destroy plan can be executed to remove all infrastructure that is in the state file, and the workspace can be deleted through the "Delete from Terraform Cloud/Enterprise" button.
Starting with Terraform Enterprise v202311-1
it is possible to create data retention policies both at the Organization and Workspace levels to set state files and configuration versions older than the allotted time in the policy to be deleted. The setting can be found at the Organization level under General and at the Workspace level under Destruction and Deletion .
Additional Information:
For further information on run logs, please see our documentation.