Skip to content

fix(toolkit): keep the HCP Terraform workspaces in local execution - #13

Merged
WhiteMuush merged 2 commits into
mainfrom
fix/hcp-local-execution
Oct 2, 2026
Merged

WhiteMuush merged 2 commits into
mainfrom
fix/hcp-local-execution

Conversation

@WhiteMuush

Copy link
Copy Markdown
Member

On a new HCP Terraform organization, Bootstrap apply failed with "az": executable file not found in $PATH. terraform init creates a missing workspace with the organization default execution mode, remote on a new organization, and a remote run has no az login for azurerm.

Changes:

  • lib/hcp.sh: hcp_ensure_local_execution <terraform dir> reads the workspace name in cloud.tf, leaves a local workspace alone, switches a remote one to local (PATCH), creates a missing one in local mode (POST) before terraform init creates it remote
  • bootstrap_terraform and infra_terraform call it before every action but output
  • token from TF_TOKEN_app_terraform_io, else the terraform login file, always sent through stdin
  • setup_hcp_organizations reuses the same token and API helpers

Tested with a fake curl under bash 3.2 and 5 (local, remote, missing, 401, no token, no organization), shellcheck -x, and read-only calls on a real organization (organization list, workspace mode, 404 on a missing workspace). The PATCH and POST were not run against the real API.

terraform init creates a missing workspace with the organization default,
remote on a new organization. A remote run has no az login, so azurerm fails
with "az: executable file not found in $PATH".
- lib/hcp.sh: hcp_ensure_local_execution reads the workspace name in cloud.tf,
  creates it in local mode when missing, switches it to local when remote
- bootstrap_terraform and infra_terraform call it before every action but output
- setup_hcp_organizations reuses the same token and API helpers
@WhiteMuush
WhiteMuush merged commit 6e464ad into main Oct 2, 2026
@WhiteMuush
WhiteMuush deleted the fix/hcp-local-execution branch October 2, 2026 07:56
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.

1 participant