Open zackdotcomputer opened 1 year ago
Thanks for reporting! Further investigation indicates that this problem is not specific to project varsets, but is a gap in support for variable sets as a whole when looking up variables for local operations - that is, the cloud
integration only looks for non-sensitive variables defined locally within the workspace and ignores variable sets entirely, whether or not they're scoped to a specific project. We'll triage this with the appropriate Terraform Cloud team.
In the meantime, you may find the import
block that was added in Terraform 1.5 useful as a way to move forward. Unlike the standalone import
command, import
blocks run remotely in TFC as part of the plan and apply workflow, so they have full access to all credentials and variables, including those provided as variable sets.
Hello, seems like the id passed into this import block has to be a string, and therefore the id cannot be passed as a sensitive variable...is there any workaround for this?
As @radditude said, an import
block is a possible workaround, but that comes with two problems: 1. it requires (for source controlled workspaces) a full commit-push-approve cycle, and 2. it runs afoul of the occasionally required operator intervention.
In my particular case an AWS runtime error left a resource in a "corrupt" state and I want to remove it from state and reimport to restore functionality; however there's no way to do this without a commit (and corresponding development/review/build cycles).
TLDR; The variable set feature for Terraform Cloud has not been properly integrated with Terraform CLI local operations like
terraform import
, meaning that this command fails saying an input "is not set, and has no default value" if that input is required for your application and also would be provided by the remote variable set.Terraform Version
Terraform Configuration Files
The
versions.tf
file:(note that in the actual project it's not ORG_NAME but rather our actual org name)
The
variables.tf
file:The
main.tf
is not relevant other than that it declares resources like anauth0_client
Debug Output
The relevant line is right before the failure:
(I've redacted the values in the
<>
because they might expose our settings more precisely.)Expected Behavior
Running
terraform import auth0_client.frontend <CLIENT_ID>
should import that client.Actual Behavior
The process fails with the error:
Steps to Reproduce
terraform import ...
command. It should fail.The fact that the import command is unable to download private variables is already documented in #26494, so that is not the new issue here. The new issue here is that the
import
command cannot access non-sensitive variables provided by variable sets.Additional Context
Note that the
terraform plan
command is able to access all variables and so it does not fail. Additionally, note that theterraform import
command only throws an error for missing variables for those provided by the variable set, so it is able to access variables provided at the workspace level.This is how I narrowed the issue down to be that
terraform import
specifically cannot access variables defined by the variable sets feature in terraform cloud.References
No response