Terraform Cloud cmd line arguments

Hi, is it possible to pass to terraform cloud the -no-color argument?

it seems to work with terraform init -no-color
but not with terraform plan -no-color

terraform init with -no-color

terraform plan with -no-color

notice the [0me[1m text

Hi @christoude_dnbgit,

I think the difference between these two commands is that terraform init always runs locally (because it’s setting up your local working directory) whereas you are using remote operations in Terraform Cloud and so terraform plan is really running in a remote Terraform Cloud agent somewhere and just streaming the logs to you over the network. Your local Terraform CLI is just printing what it was sent by Terraform Cloud onto stdout verbatim.

Therefore I guess the -no-color setting is being handled by your local Terraform CLI but the remote Terraform running in Terraform Cloud can’t see it and so it’s just returning the default output with all of the color codes still intact. I don’t see any way in the Terraform Cloud API for Terraform CLI to request running Terraform in -no-color mode.

However, I think there would be a way to get that result by changing the settings for your Terraform Cloud workspace to force setting the -no-color option for all commands running in the remote execution environment. To do this, you’d use the Workspace-specific Variables settings, being careful to set an Environment Variable rather than a Terraform Variable, since the latter is for defining values for variable blocks in your root module.

The environment variable name to set would be TF_CLI_ARGS and the value would be -no-color. Terraform CLI checks for that environment variable and behaves as if you’d included all of the arguments from that variable as part of the command line.

If you do this note that you’re changing what the remote Terraform process is generating, and so this will also affect the logs shown in the Terraform Cloud web UI; both Terraform CLI and the web UI are using the same data.

That did the trick, thanks for the detailed explanation!