terraform import
pulls variables from Terraform Cloud when set to "local" execution
#29966
Labels
backend/remote
bug
cloud
Related to Terraform Cloud's integration with Terraform
new
new issue not yet triaged
Summary
When using Terraform Cloud as the backend in "local" mode, there is inconsistent behavior for non-sensitive variable resolution between
terraform import
andterraform plan
.I believe this is inconsistent behavior introduced by the interaction with Terraform Cloud. I don't think this behavior is caused by Terraform Cloud specifically.
Terraform Version
The most recent test was with v1.0.11, although this behavior has been present since at least v0.13.1.
Terraform Configuration Files
I can provide some configuration here, but this behavior is present regardless of configuration files.
Debug Output
TODO
Expected Behavior
My expectation is that
terraform import
should use the same variables asterraform plan
when the Terraform Cloud workspace is set to "Local".Actual Behavior
terraform import
pulls non-sensitive variables from Terraform Cloud, whereterraform plan
only uses locally defined variables.Steps to Reproduce
local.auto.tfvars
file with the same variable name you have remote, but with correct AWS credentialsterraform plan
locally, see that the plan uses the value fromlocal.auto.tfvars
terraform import
locally, see that the import uses the value from Terraform CloudAdditional Context
Terraform is running directly from my CLI. Commands are exactly
terraform plan
andterraform import '<address>' '<id>'
References
I couldn't find any other open issues with similar issues.
Investigation
It seems this step in the import workflow isn't necessary when the backend is a Terraform Cloud workspace set to "Local" execution: https://github.com/hashicorp/terraform/blob/v1.1.0-beta1/internal/backend/remote/backend_context.go#L95
When debugging locally, I can see the variables are correctly set after the
c.collectVariableValues()
step hereBut during the
local.LocalRun(..)
here it grabs the remote variables here and overrides existing local variables hereThe text was updated successfully, but these errors were encountered: