8000 [IPL-7725] Adding Support for Calls to `/workspaces/{external_id}/all-vars` API Endpoint on HCP Terraform by debrin-hc · Pull Request #1105 · hashicorp/go-tfe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[IPL-7725] Adding Support for Calls to /workspaces/{external_id}/all-vars API Endpoint on HCP Terraform #1105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jun 13, 2025

Conversation

debrin-hc
Copy link
Contributor
@debrin-hc debrin-hc commented May 14, 2025

Description

This PR adds the support to make calls to the /workspaces/{external_id}/all-vars V2 API, which now returns the list of all variables accessible in a workspace. This list now includes all variables inherited from organization and project level variable sets in HCP Terraform. The existing V2 API /workspaces/{external_id}/vars only returns the list of variables defined in a workspace, and excludes inherited but not overwritten variables from varsets.

With this change, the remote / backend context in terraform core can effectively call this API to fetch the list of accessible variables, effectively fixing the bug mentioned in IPL-7725. The bug talks about such inherited but not overwritten variables defined in a terraform configuration, which causes a "No value for required variable" error while doing a terraform import from the CLI.

Testing plan

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

(base) amartyamajumdar@amartyamajumdar-FGXW6P4DYL go-tfe % envchain go-tfe go test -run TestVariablesListAll -v ./...
?   	github.com/hashicorp/go-tfe/examples/backing_data	[no test files]
?   	github.com/hashicorp/go-tfe/examples/configuration_versions	[no test files]
?   	github.com/hashicorp/go-tfe/examples/projects	[no test files]
?   	github.com/hashicorp/go-tfe/examples/registry_modules	[no test files]
?   	github.com/hashicorp/go-tfe/examples/run_errors	[no test files]
?   	github.com/hashicorp/go-tfe/examples/state_versions	[no test files]
?   	github.com/hashicorp/go-tfe/examples/users	[no test files]
?   	github.com/hashicorp/go-tfe/examples/workspaces	[no test files]
?   	github.com/hashicorp/go-tfe/mocks	[no test files]
?   	github.com/hashicorp/go-tfe/examples/organizations	[no test files]


=== RUN   TestVariablesListAll
=== RUN   TestVariablesListAll/when_/workspaces/{external_id}/all-vars_API_is_called
=== RUN   TestVariablesListAll/when_workspace_ID_is_invalid_ID
--- PASS: TestVariablesListAll (5.34s)
    --- PASS: TestVariablesListAll/when_/workspaces/{external_id}/all-vars_API_is_called (0.18s)
    --- PASS: TestVariablesListAll/when_workspace_ID_is_invalid_ID (0.00s)
PASS
ok  	github.com/hashicorp/go-tfe	6.246s
(base) amartyamajumdar@amartyamajumdar-FGXW6P4DYL go-tfe %

Rollback Plan

Not required. This adds support for a new V2 API and does not affect any existing workflows.

8000
…ed with a workspace including

variables that inherited from organization and/or project variable sets. The List API does not
include variables that are inherited from varsets but not overwritten in the workspace.
@debrin-hc debrin-hc changed the title Ipl 7725 [IPL-7725] Adding Support for Calls to /workspaces/{external_id}/all-vars Endpoint on HCP Terraform May 15, 2025
@debrin-hc debrin-hc marked this pull request as ready for review May 15, 2025 06:25
@debrin-hc debrin-hc requested a review from a team as a code owner May 15, 2025 06:25
@debrin-hc debrin-hc changed the title [IPL-7725] Adding Support for Calls to /workspaces/{external_id}/all-vars Endpoint on HCP Terraform [IPL-7725] Adding Support for Calls to /workspaces/{external_id}/all-vars API Endpoint on HCP Terraform May 19, 2025
@datadog-terraform-cloud-hashicorp
Copy link
datadog-terraform-cloud-hashicorp bot commented May 22, 2025

Datadog Report

Branch report: IPL-7725
Commit report: 6612cb1
Test service: hashicorp/go-tfe

✅ 0 Failed, 1451 Passed, 174 Skipped, 19m 54.34s Total Time
➡️ Test Sessions change in coverage: 1 no change

ctrombley
ctrombley previously approved these changes Jun 11, 2025
Copy link
Collaborator
@ctrombley ctrombley 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, thanks!

CHANGELOG.md Outdated
@@ -28,6 +28,8 @@

* Add BETA support for use of OPA and Sentinel with Linux arm64 agents, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users @natalie-todd [#1090](https://github.com/hashicorp/go-tfe/pull/1090)

* Add support for HCP Terraform `/api/v2/workspaces/{external_id}/all-vars` API endpoint to fetch the list of all variables available to a workspce (include inherited variables from varsets) by @debrin-hc [#1105](https://github.com/hashicorp/go-tfe/pull/1105)

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be moved to the Unreleased version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@debrin-hc debrin-hc merged commit 3b35abc into main Jun 13, 2025
8 checks passed
@debrin-hc debrin-hc deleted the IPL-7725 branch June 13, 2025 05:21
Copy link

Reminder to the contributor 95FF that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0