You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
terraform {
cloud {} # source of the errorrequired_providers {
# something else
}
}
Note the empty cloud block; its fields should be parsed from the environment variables TF_WORKSPACE & TF_CLOUD_ORGANIZATION. Running the CLI myself, I manage to get it working.
I'm getting my environment variables from a dot env file using the following snippet of code
I have verified that I have correct access to the env variables after the previous statements are executed. But whenever I initialise terraform with tf.Init(context.Background(), tfexec.Upgrade(true)), it complains about not specifying a workspace (something that does not happen when using the CLI directly).
The interesting thing is, if I do manually specify TF variables in the HCL files, it all works. So it seems not to be a problem from not parsing environment variables but outright ignoring TF_WORKSPACE? Is this a possibility?
The following is my main, in case you need to see the entire code:
Correction: I only specified the workspace name (equivalent to TF_WORKSPACE env var) in the HCL file, hence TF_CLOUD_ORGANIZATION and TF_TOKEN_app_terraform_io both seem to have been taken into account via terraform-exec. So it must be a TF_WORKSPACE issue?
I guess this must relate back to #247 which has an open PR #259, but it seems it never got merged. Should I have any expectations of this ever being merged? Or move away from using terraform-exec and use the cli directly with, possibly, os/exec?
sergiorivera50
changed the title
Environment variables not taken into account when using empty Cloud block
TF_WORKSPACE not parsed for empty Cloud block
Nov 7, 2022
I have the following
versions.tf
Note the empty cloud block; its fields should be parsed from the environment variables
TF_WORKSPACE
&TF_CLOUD_ORGANIZATION
. Running the CLI myself, I manage to get it working.I'm getting my environment variables from a dot env file using the following snippet of code
I have verified that I have correct access to the env variables after the previous statements are executed. But whenever I initialise terraform with
tf.Init(context.Background(), tfexec.Upgrade(true))
, it complains about not specifying a workspace (something that does not happen when using the CLI directly).The interesting thing is, if I do manually specify TF variables in the HCL files, it all works. So it seems not to be a problem from not parsing environment variables but outright ignoring TF_WORKSPACE? Is this a possibility?
The following is my main, in case you need to see the entire code:
The text was updated successfully, but these errors were encountered: