Overview
This article explains the "terrform: argument list too long" error that occurs after an HCP Terrraform RUN. This issue typically affects agent-based runs.
Error Message:
Operation failed: xxxxxxxxxxxxx
terraform: argument list too long
Root Cause
After the agent works with the execution command (Sent to Terraform CLI), it may inadvertently assemble a command line that exceeds the OS based limits for this. In other words, sending too many parameters for one or more arguments for Terraform CLI to process.
Solution
There are multiple approaches to solve this. The most common is to locate the argument that is being sent with longer than usual parameters. Short them, or split them.
Review the OS level configuration. Check if the issue was triggered by automation that caused the parameter data to grow and reach this limit.
Other workarounds include refactoring your code, if paths are involved, using relative vs absolute, and/or passing the arguments via a file, like using -var-file
argument:
terraform plan -var-file=filename.tfvars
Conclusion
This issue can show up when using agent-based runs, and sending too long parameters to Terraform CLI, however is not caused by Terraform itself, but by a limit imposed by the underlying Operating System where the agent is running.