Repository navigation
fix(toolkit): keep the HCP Terraform workspaces in local execution - #13
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On a new HCP Terraform organization, Bootstrap apply failed with
"az": executable file not found in $PATH.terraform initcreates a missing workspace with the organization default execution mode, remote on a new organization, and a remote run has noaz loginfor azurerm.Changes:
lib/hcp.sh:hcp_ensure_local_execution <terraform dir>reads the workspace name incloud.tf, leaves a local workspace alone, switches a remote one to local (PATCH), creates a missing one in local mode (POST) beforeterraform initcreates it remotebootstrap_terraformandinfra_terraformcall it before every action butoutputTF_TOKEN_app_terraform_io, else theterraform loginfile, always sent through stdinsetup_hcp_organizationsreuses the same token and API helpersTested with a fake
curlunder 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.