- Preparing the repository and making the initial commit
- Connecting the workspace to your VCS provider
- Configuring trigger options and speculative plans
- Making a code change to trigger a run
- Reviewing, confirming, and applying the plan
- Benefits and recommended settings
Preparing the repository and initial commit
In this example we started with a repository that only contained a.gitignore. Locally we added Terraform files (main.tf, providers.tf, variables.tf). The primary resources in main.tf looked like this:
Connecting the workspace to the repository
To convert a workspace from CLI-driven to VCS-driven:- Open the workspace in HCP Terraform: https://app.terraform.io
- Go to Settings → Version Control.
- Switch to “Version Control Workflow” (from CLI-driven).
- Choose your VCS provider (GitHub, GitLab, Bitbucket, Azure DevOps) and follow the guided sign-in and authorization flow.
- Select the repository and branch the workspace should track. Optionally set a Terraform working directory (leave blank for repository root).


Trigger options and speculative plans
When you enable VCS integration you can configure how runs are created and what events trigger them: branch pushes, tags, pull requests, and more. You can also choose whether the workspace should auto-apply plans or require manual confirmation.- Branch-based runs: run on commits to specific branches.
- Pull request speculative plans: preview changes without updating state.
- Tag-based runs: useful for release-related automation.
- Auto-apply: toggle to automatically apply successful plans (use carefully).


Making a code change and letting VCS trigger a run
We updatedmain.tf to add an Environment tag to both the private and public subnets. Example updated public subnet:
Confirming and applying the run
From the workspace run page you can inspect the speculative plan, review diffs, and either Confirm & Apply or discard. After you confirm, the run performs the apply step and updates the managed state. A new state version is recorded in the workspace’s States view.
Quick reference — VCS-driven workspace checklist
Benefits of a VCS-driven workflow
- Automated speculative plans for each commit or pull request.
- Clear audit trail: commits + run history explain who changed what and why.
- Safer reviews: PR previews allow teams to see proposed changes without touching state.
- Optional auto-apply for trusted branches or CI releases.
When a workspace is VCS-connected, each commit can trigger a speculative plan automatically. If you prefer not to auto-apply changes, leave auto-apply disabled so you can review and confirm plans before applying.