Skip to content

Conversation

debrin-hc
Copy link
Contributor

@debrin-hc debrin-hc commented Jul 14, 2025

Description

Original Problem

While doing a terraform import, it was observed that variables inherited from variable sets in HCP Terraform were not
getting 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:

  • variables declared in the workspace and not overwritten by organization / project variable set
  • variables inherited from organization / project variable sets and not overwritten by workspace variables

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, and
importing variables from variable sets works as expected.

Testing

  1. Verified that the issue is fixed by running terraform import on a workspace with inherited variables from variable
    sets. Evidence attached below.

Documentation and External References

  1. Fixes JIRA: IPL-7725
  2. ADR Documentation: TF-033
  3. go-tfe PR: #1105

Target Release

1.13.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

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

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

debrin-og and others added 6 commits June 18, 2025 10:13
… all variables

 accessible to a workspace. This should include:
 - variables declared in the workspace and not overwritten by organization / project varset variables
 - variables inherited from organization / project varsets and not overwritten by workspace variables

Other changes: Adding mocks for new functions in go-tfe after version upgrade
@debrin-hc debrin-hc requested review from a team as code owners July 14, 2025 08:26
@debrin-hc debrin-hc marked this pull request as draft July 14, 2025 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants