Developers want a temporary environment for each feature branch: a workspace that runs that branch's code, receives the team's dev variable set, and is removed when the branch is merged. The platform team wants this automated through its pipeline. What should it use?
Select an answer to reveal the explanation.
Short Explanation
Treat workspaces like cattle, not pets: your pipeline stamps one out per branch with the tfe provider or the API, and removes it at merge. Speculative plans only preview; they never build anything.
Full Explanation
Workspaces can be created programmatically, either with the HCP Terraform API or with the tfe provider's tfe_workspace resource, which accepts a vcs_repo block whose branch argument selects the branch to run, along with a project and other settings. A pipeline that reacts to branch creation can create a workspace for that branch, attach the dev variable set with a variable set assignment, and queue a run; on merge it can queue a destroy run and then delete the workspace. Auto-destroy settings, inherited from the project if desired, add a safety net for branches nobody cleans up. A run trigger queues runs in an existing downstream workspace after an upstream apply succeeds; it cannot create workspaces. Speculative plans on pull requests are plan-only and cannot be applied, so they never provision an environment. Variable sets supply variables to existing workspaces; they never create workspaces. Exam caveat: deleting a workspace does not destroy its infrastructure, so the pipeline must destroy resources before deleting the workspace, and tfe_workspace offers a force_delete argument that bypasses the safe-delete check. Operational check: push a test branch, confirm a workspace appears with that branch in its VCS settings and the dev variable set attached, then merge and confirm the resources and workspace are removed.