Problem
When running a plan in a Terraform Enterprise workspace, the operation fails after the plan phase with an illegal slug error. This prevents the workspace from proceeding to an apply.
Terraform will perform the following actions:
# null_resource.test will be created
+ resource "null_resource" "test" {
+ id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
Operation failed: failed packing filesystem: illegal slug error: invalid symlink ("/home/tfc-agent/.tfc-agent/component/terraform/runs/run-HUDejy6P2Y3Hnxnc/config/stage/.terraform/providers/registry.terraform.io/hashicorp/null/3.1.1/linux_amd64" -> "/home/tfc-agent/.tfc-agent/component/terraform/runs/run-HUDejy6P2Y3Hnxnc/.terraform.d/plugins/registry.terraform.io/hashicorp/null/3.1.1/linux_amd64") has external targetPrerequisites
This issue occurs in environments with the following configuration:
- Terraform Enterprise version
v202311-1orv202312-1. - Using a Terraform Bundle as documented in the Terraform Bundle README.
- The workspace uses a VCS integration with a Terraform Working Directory specified.
Cause
This error occurs due to a compatibility issue in specific versions of Terraform Enterprise. The tfe-agent was updated to version 1.13.0 in TFE v202311-1 and 1.14.0 in TFE v202312-1. These agent versions do not work correctly with Terraform Bundles when the workspace is configured to use a VCS-backed working directory.
Solutions
Solution 1: Upgrade Terraform Enterprise
Upgrade the Terraform Enterprise environment to version v202401-1 or newer. This version includes a fix for the agent incompatibility.
Solution 2: Downgrade the TFE Agent
If an immediate upgrade is not possible, you can resolve the issue by configuring your Terraform Enterprise instance to use a custom agent image based on the older 1.12.0 version.
-
Create a custom agent image. Follow the guide on How to Add Custom Certificates to Terraform Agents for use with Terraform Enterprise, using the following
Dockerfileto specify agent version1.12.0.FROM hashicorp/tfc-agent:1.12.0 USER root ENV TFC_AGENT_AUTO_UPDATE=disabled USER tfc-agent
-
Update your Terraform Enterprise Flexible Deployment Options (FDO) settings to use this custom agent image.
TFE_RUN_PIPELINE_IMAGE: "your-registry/custom-agent-image:latest"
Outcome
After applying one of the solutions, Terraform plans should execute successfully without the illegal slug error.
Additional Information
- For general guidance on troubleshooting plan failures, refer to Troubleshoot Plan operation failures in Terraform Enterprise.