Skip to content

Conversation

debrin-hc
Copy link

@debrin-hc debrin-hc commented Jun 16, 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.14.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.

Testing Evidence

evidence__ipl_7725__hcp_workspace_variables evidence__ipl_7725__terraform_config evidence__ipl_7725__terraform_import_result

@debrin-hc debrin-hc requested review from a team as code owners June 16, 2025 11:08
@xiehan
Copy link
Member

xiehan commented Jun 19, 2025

@hashicorp/terraform-aws @hashicorp/tf-eco-hybrid-cloud @hashicorp/terraform-azure Can you all check whether these dependency updates look safe to you and/or test as needed?

radeksimko
radeksimko previously approved these changes Jun 19, 2025
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ok from my POV but I would defer to the Core Cloud team on the actual logic being changed here.

jar-b
jar-b previously approved these changes Jun 19, 2025
Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@vignesh-jayabalan
Copy link

@iBrandyJackson and @katbyte : Can you folks, please help as well.

alexsomesan
alexsomesan previously approved these changes Jun 25, 2025
Copy link
Member

@alexsomesan alexsomesan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from the Kubernetes perspective.

BBBmau
BBBmau previously approved these changes Jun 26, 2025
Copy link

@BBBmau BBBmau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, the dependencies changes on the gcs backend are very minor

jackofallops
jackofallops previously approved these changes Jun 30, 2025
Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine from Azureland 👍

Copy link
Contributor

@Maed223 Maed223 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from the Core Cloud perspective 👍

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.

10 participants