[IPL-7725] Updating Calls to the Remote HCP Terraform API to Retrieve All Workspace Variables #37241
+83
−64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Original Problem
While doing a
terraform import
, it was observed that variables inherited from variable sets in HCP Terraform were notgetting resolved, which caused the No value for required variable error. Usually, in such cases, terraform would make
an API call to HCP Terraform (via go-tfe client) to retrieve the list of variables accessible to the workspace. However,
the HCP Terraform API failed to include inherited variables that were not overwritten by workspace variables, which led
to the error.
Proposed Solution
We updated the HCP Terraform API to include the following variables for a workspace:
The updated API was included in the latest version (v1.83.0) of the go-tfe client, and this PR updates the go-tfe client
version and updates the API calls in the
terraform import
command to use the new API.Note - the terraform
import
block does not face this issue since it is executed during a plan / apply run, andimporting variables from variable sets works as expected.
Testing
terraform import
on a workspace with inherited variables from variablesets. Evidence attached below.
Documentation and External References
Target Release
1.13.x
Rollback Plan
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
NO
CHANGELOG entry
Testing Evidence