cloud block, workspace variables and execution mode. This page covers what to add when you run several brands, or when you want a plan on every pull request.
Projects and workspaces
HCP Terraform has three levels: organization, project and workspace.- One workspace per tenant. A workspace holds one state file.
- One project per brand, agency or business unit.
cloud block, alongside the workspace:
Access
A project holds a brand’s dev, QA and production workspaces, so granting a team the project gives them production as well.- Grant the project to the people who work on that brand.
- Grant the production workspace separately, to a smaller group.
Plan every pull request
Connect HCP Terraform to your repository and it plans each pull request, then applies on merge.- In Settings > Version Control > Providers, add GitHub and install the HCP Terraform GitHub App on your repository.
- Create each workspace with the Version control workflow, pointed at that repository.
- Set the VCS branch and the Terraform working directory, such as
envs/dev. - Turn Auto-apply off, so each run waits for approval.
Working directory and run triggers
The working directory keeps each workspace to its own environment folder. By default it also limits which changes start a run. Set Automatic run triggering to Always trigger runs, or add trigger patterns covering both folders:Plan from your machine
A workspace connected to version control still accepts a plan from the command line:Example
multi-brand-hcp is a working repository for several brands on HCP Terraform, with a project and workspace declared per environment.
