Problem
A Terraform Enterprise server may experience disk space issues due to the accumulation of slug files. These files are typically located in /opt/terraform/aux/archivist/terraform/slugs/ for Replicated installations or /var/lib/terraform-enterprise/aux/archivist/terraform/slugs for Flexible Deployment Options (FDO) with Docker. These files, which are associated with VCS-driven workspaces, can grow in size and become difficult to manage when workspaces must remain active and cannot be deleted.
Cause
In Terraform Enterprise, slug files are archived configuration versions that support VCS-driven workspaces by preserving historical versions for workspace consistency and accurate state management. Over time, as you update configurations in your VCS repositories, these slug files increase in number and size, consuming substantial disk space. Terraform Enterprise does not automatically delete old slugs, as they are essential for maintaining consistency in workspace runs and re-runs.
Solutions
Here are several approaches to manage disk space consumed by slug files.
Solution 1: Delete Unused Workspaces
If some workspaces are no longer active or needed, deleting them will also clean up their associated slug files and free up disk space immediately.
To delete a workspace, navigate to the organization that contains the workspace. Select the workspace, go to the Settings menu, and choose Destruction and Deletion. This action permanently removes the workspace and its associated data from Terraform Enterprise. For detailed steps, refer to the guide on How to delete a workspace from HCP Terraform or Terraform Enterprise.
Solution 2: Archive Unused Configurations
For API-driven workspaces, Terraform Enterprise does not automatically archive old configuration versions because it cannot re-fetch the files from a VCS provider. You can manually archive these configurations to remove older, unused slugs. This approach allows you to purge historical versions that are no longer needed while ensuring active workspaces continue to function correctly.
Solution 3: Increase Disk Storage
If all workspaces are critical and cannot be deleted or archived, consider increasing the disk capacity allocated to your Terraform Enterprise instance. This is a longer-term solution that allows the server to store more slug files without causing space-related issues.
Additional Information
For more details on managing Terraform Enterprise, consider reviewing the official documentation on administration and operational best practices.