tfe
ignores token =
parameter, only accepts TFE_TOKEN
in HCP Terraform workspace variables
#1529
Labels
tfe
ignores token =
parameter, only accepts TFE_TOKEN
in HCP Terraform workspace variables
#1529
Terraform Enterprise version
HCP Terraform
Terraform version
Terraform Configuration Files
terraform.tf
:main.tf
:Debug Output
Expected Behavior
In normal "Remote" execution on HCP Terraform, the provider should have used the token being explicitly passed in the provider config:
According to the
tfe
provider docs, Authentication section, the provider should accept the token either by explicitly configuring as above, or by having it in theTFE_TOKEN
environment variable in the run.If passed in to the provider config as a variable, it should accept a variable value in normal ways, including passing in a
.tfvars
file, Using aTF_VAR_***
environment variable, or-var
at the CLI that kicks off the run. When this codebase is used without thecloud { }
block during local execution, this works as the docs say it should.Actual Behavior
When the run kicks off inside the remote runner,
tfe
provider is either failing to use the variable-provided token at all, or a token provided for the run is "winning" and being used, but doesn't have access to read other resources from HCP Terraform. Whatever token the provider has picked up is resulting inunauthorized
errors from the API when trying to refresh state at the beginning of aterraform plan
operation:If I pass the exact same token to the provider by placing a
TFE_TOKEN
variable, of typeenv
, into the HCP Terraform workspace variables, then the provider uses the correct token and theterraform plan
run succeeds.Additional Context
As mentioned above, this code (including the ability to pass a token explicity in the provider config) works successfully before using HCP Terraform via
cloud { }
configuration.I believe either of two paths forward would work for resolving this issue:
tfe
provider, wherein it should accept a token via explicit definition, including by variable passing into that explicit config, orTFE_TOKEN
environment variable option is honored.The text was updated successfully, but these errors were encountered: