Skip to content

Commit

Permalink
remove workspace env var and not set it to an empty string.
Browse files Browse the repository at this point in the history
Setting the environment variable to an empty string confuses the
terraform binary as seen below:

```
TF_WORKSPACE= terraform init -no-color -input=false -get=false -upgrade=false -backend=false

Error: Terraform Cloud returned an unexpected error

invalid value for workspace
```

With this patch the `TF_WORKSPACE` will not exist and avoids the above
problem. I have tested this locally with terraform 1.4.5 and it works.
  • Loading branch information
bjhaid committed May 2, 2023
1 parent 1b77141 commit 47625b8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tfexec/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (tf *Terraform) buildEnv(mergeEnv map[string]string) []string {
env[automationEnvVar] = "1"

// force usage of workspace methods for switching
env[workspaceEnvVar] = ""
delete(env, workspaceEnvVar)

if tf.disablePluginTLS {
env[disablePluginTLSEnvVar] = "1"
Expand Down

0 comments on commit 47625b8

Please sign in to comment.