Skip to main content
Now that the Terraform state has been migrated into an HCP (Terraform Cloud) workspace and the workspace is managing both state and configuration, the next step is converting that workspace from a CLI-driven workflow to a VCS-driven workflow. With a VCS-driven workspace, commits to your Git repository automatically trigger Terraform runs (plans) in the workspace, and pull requests can trigger speculative plans for previewing changes.
The image shows a dashboard for a Terraform Cloud workspace named "hcp-demo," displaying details about the latest run triggered via CLI, along with resource and execution metrics.
Overview — high-level steps
  • Push your Terraform configuration to a Git repository (e.g., GitHub).
  • Configure your Terraform Cloud workspace to use that repository and branch.
  • Commits to the configured branch will trigger runs (plans) automatically; pull requests can trigger speculative plans.
  • Review and optionally apply plans from the Terraform Cloud UI or enable Auto-Apply for automatic applies.
Preparing your repository
  1. Confirm the repository contains the Terraform files you want Terraform Cloud to run.
  2. Push the files to the branch that the workspace will monitor.
Example: verify local git status
Sample output:
Initial Terraform configuration Below is the initial main.tf used in this demo — a simple VPC and a private subnet.
Stage and push these files to your remote repository:
Successful push feedback (example):
Configure the workspace to use VCS
  1. In Terraform Cloud, open the workspace.
  2. Go to Settings → Version Control.
  3. Connect or select your VCS provider (GitHub, GitLab, Bitbucket, Azure DevOps, etc.).
  4. Pick the repository and branch you pushed your code to, and save the settings.
The image shows a web interface for configuring version control settings in Terraform Cloud, where a repository is being selected for hosting Terraform source code.
VCS configuration options
  • Working directory: set a subdirectory if your Terraform root is not at the repository root (leave blank for root).
  • Auto-apply: enable to automatically apply successful plans.
  • Trigger type: branch or tag based; pull request behavior (speculative plans) depends on provider and integration settings.
Connecting a workspace to VCS enables automatic plans whenever commits are pushed; pull requests can trigger speculative plans. You can enable Auto-Apply to apply changes automatically after a successful plan, but it’s common to require manual approval for production-sensitive workspaces.
First run after connecting VCS As soon as the workspace is connected to the repository and branch, Terraform Cloud queues an initial plan. This first run maps the repository configuration to the state currently managed by the workspace. In many cases this initial plan will report no changes if the state and configuration already match.
The image shows a Terraform Cloud web interface with a workspace titled "hcp-demo." It displays details about the latest run, resources, and settings.
Demonstrating an update via VCS To demonstrate how commits trigger runs, update your local configuration (for example, add environment tags to the private subnet and create a public subnet). The updated portion of main.tf:
Commit and push the changes:
Example push output:
Automatic runs and reviewing plans After the push completes, Terraform Cloud detects the commit and automatically triggers a run for the workspace. If this change were part of a pull request, Terraform Cloud would present a speculative plan tied to that PR. Each run is associated with the commit that triggered it so you can see exactly what Terraform will change.
The image shows a Terraform Cloud interface displaying run details of a plan that changed subnet tags to "development," with a focus on AWS subnets configuration.
From the run details you can:
  • Review the plan, then click Confirm & Apply to execute the changes, or
  • Enable Auto-Apply so successful plans are applied automatically.
I chose Confirm & Apply in this demo. Terraform Cloud executed the apply, updated the workspace state, and created a new state version. You can verify the new state under the workspace States tab. Benefits of a VCS-driven Terraform workflow Links and references Next steps With the workspace now VCS-connected, you can extend this pattern to:
  • Create additional workspaces per environment (dev, staging, prod),
  • Use workspace variables and policies to enforce guardrails,
  • Integrate CI/CD pipelines to manage more complex workflows.
Now that the workspace is VCS-driven, subsequent changes to infrastructure will be governed by commits and PR workflows, improving collaboration, traceability, and automation.

Watch Video