-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Allow setting HCP Terraform "Working Directory" setting when creating a new workspace #35396
Comments
Hi @rmcolbert, Thanks for filing the issue. All
The CLI help text all appears to be up to date, but it looks like the Thanks! |
That doesn't create/update the "Terraform Working Directory" in the tfc workspace config itself so while the cli runs from inside the chdir, the tfc workspace job tries to run from the root and fails. |
Thanks @rmcolbert, I'll flag this for the |
From reading the above it seems like there's a bit of collision of terminology here, so I just want to try to clarify what this represents to make sure everyone's talking about the same thing. 😀 HCP Terraform workspaces have a setting called "working directory" which contains a relative path from the root of the workspace's main source package (typically a Git repository) to the directory containing the root module of the workspace's Terraform configuration. That is a separate idea from Terraform CLI's own working directory, which is typically just whatever directory you ran HCP Terraform features then use that in two main ways:
Since Terraform CLI's Although this issue is focused only on the working directory setting, I think resolving it means deciding whether and how Terraform CLI should deal with HCP Terraform-specific workspace settings in general. Adding new options to As @jbardin said, this will ultimately be driven by the HCP Terraform teams. I just wanted to add some extra context because it seemed like the goals of this issue might be unclear to a hypothetical reader that isn't familiar with HCP Terraform features. |
@apparentlymart Thank you for adding clarity and context around my request. I would like to point out that the CLI and HCL files already blur the line around this point by having the remote state and cloud configuration being able to leverage the workspace commands. Perhaps if it was part of the cloud config block instead of a direct CLI command parameter it would fit the bill for not cluttering the CLI command while still providing an avenue for the feature. Especially since 1.6.x added the ability for setting the project assigned to a new workspace in TFC when the "terraform workspace new" command is executed. |
Terraform Version
Use Cases
We create terraform modules for consumption by other teams. To do this, we leverage a test folder to hold terratest configs referencing the parent path to run CI/CD pipeline testing. This works great when we manually create the workspaces (via API call) and set the working directory to the test folder but if we wanted to stay purely in the CLI, having the ability to set the working directory when using cloud or remote state configs would simplify our workflow.
Attempted Solutions
Creating the workspaces using TFC REST API works but requires additional management and overhead.
Proposal
Add a flag or argument to the "terraform workspace new" command to add an optional workingdir relative path.
terraform workspace new -workingdir test TestWorkspace
-or to match the actual documentation-
terraform workspace new TestWorkspace test
Note: There is a documentation bug where all of the workspace related commands end with [DIR] implying you could pass in a directory path of some kind.
References
No response
The text was updated successfully, but these errors were encountered: