Introduction
Problem
Running a plan you get the following error after the plan successfully showed the executed plan. This prevents the workspace to continue with 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 target
Prerequisites
- TFE version v202311-1/v202312-1
- Using a Terraform Bundle as documented here
- The workspace uses a VCS with a Terraform Working Directory
Cause
This error happens with a combination of versions and usage in Terraform Enterprise as described in the prerequisites.
With version v202311-1/v202312-1 there is an update of the tfe-agent to version 1.13.0/1.14.0. This new agent is not able to work properly with the Terraform Bundle and the workspace using a VCS with a Terraform Working Directory
Solution 1:
Upgrade the TFE environment to version v202401-1. This is scheduled to be release on January 29 2024.
Solution 2:
Alter the Terraform Enterprise v202311-1/v202312-1 to use a custom agent with version 1.12.0.
- Create a custom agent as documented here. Please notice to use the agent version 1.12.0
example:
FROM hashicorp/tfc-agent:1.12.0
USER root
ENV TFC_AGENT_AUTO_UPDATE=disabled
USER tfc-agent
- Alter your TFE FDO settings to use this custom-agent-image
TFE_RUN_PIPELINE_IMAGE: "custom-agent-image:latest"
Outcome
When applying a solution the plans should work as expected