Skip to main content
Welcome back. In this lesson we’ll create an HCP Terraform workspace and configure its core settings so you can migrate a local Terraform run into HCP Terraform. Prerequisite: you should be logged into HCP Terraform with Workspaces selected in the left navigation. To begin, click New and choose Workspace.
The image shows a web interface for creating a new workspace on a platform called Terraform. There's a pop-up asking to select a project for the workspace.
  1. Select the Default Project (a project is required) and click Create. Projects are an organizational construct and are useful for grouping related workspaces.
Next you will choose the workspace workflow. For this demo we’ll use a CLI-driven workflow so you can migrate an existing local Terraform configuration into HCP Terraform. You can change this to a VCS-driven workflow later if desired.
The image shows a Terraform interface for creating a new workspace, with options for different workflows: Version Control, CLI-Driven, and API-Driven. The left sidebar includes navigation options like Projects, Stacks, and Workspaces.
  1. Choose CLI-driven, give the workspace a name (we use hcp-demo in this example), confirm the Default Project, optionally add a description, and click Create.
The image shows a web interface for creating a new workspace in HCP Terraform, with fields for entering a workspace name, selecting a project, and adding an optional description. The left sidebar includes navigation options like Projects, Stacks, and Registry.
Workspace overview and important details
  • After creation you’ll see the workspace name and ID at the top. The ID is useful when integrating external systems or APIs.
  • You can lock the workspace, view the initial resource count (starts at zero), and see the Terraform version HCP will use to run plans and applies. You can change the version in the workspace settings.
  • The right-hand summary displays execution mode (Remote, Local, Agent), auto-apply, allowed run sources (API/UI/VCS), and the current status (for example, “waiting for configuration” when nothing is connected).
Below the header you’ll also find example HCL to use in a local Terraform configuration when migrating to this workspace. Copy this cloud block into your local terraform configuration to point it at the new HCP workspace:
terraform {
  cloud {
    organization = "krausen-hcp"

    workspaces {
      name = "hcp-demo"
    }
  }
}
Use this cloud block when migrating your local configuration and state into HCP Terraform.
The image shows a web interface for a Terraform workspace named "hcp-demo" under the organization "krausen-hcp." The workspace has no resources and includes sections like API-driven runs, contributors, and a sidebar menu with various options.
Callouts & resource licensing
HCP Terraform measures licensing by “resources under management” (RUM). On the free tier you can manage up to 500 resources across your workspace(s). A “resource” is any Terraform-managed object (for example, VPC, subnet, instance, DNS record). Plan workspaces accordingly to avoid exceeding your RUM limits.
State, runs, and navigation
  • Use the left navigation to open Runs (view queued and past runs), State (saved state files), and other workspace features such as Search and Import.
  • Click State after performing runs to view the saved state files and version history.
The image shows a Terraform workspace page titled "hcp-demo" with no saved states, indicating it is a demo workspace for a course. There are options for locking and creating a new run, with navigation on the left.
Variables and secrets
  • Each workspace can have Terraform input variables and environment variables configured via the Variables section.
  • Click Add Variable, choose the variable type (Terraform or Environment), enter a key and value, and mark it Sensitive if it should be encrypted and masked.
The image shows a web interface for HashiCorp's Terraform Cloud, specifically the "Variables" section of a workspace named "hcp-demo". It includes options for managing variables, running new tasks, and viewing sensitive variables.
Sensitive variables are encrypted and cannot be read back after creation. You can update (overwrite) a sensitive value, but you cannot retrieve the original value from the UI—store your secrets securely elsewhere if you need a retrievable copy.
Workspace settings — execution & versioning
  • Execution mode options: Project Default, Remote, Local, Agent. For this demo choose Remote execution so HCP executes plans and applies.
  • Toggle Auto-apply if you want applies to run automatically after a successful plan.
  • You can set the Terraform working directory, configure remote state sharing, and choose which run sources are allowed.
  • Be sure to align the workspace Terraform version with your local environment (for example, select 1.1.2 if that’s what you use locally) and click Save settings.
The image shows the workspace settings of an HCP Terraform application, with a focus on selecting the execution mode, which includes options like Project Default, Remote, Local, and Agent. The "Remote (custom)" option is selected.
Quick reference: Workspace controls and integrations
FeaturePurposeExample / Note
Execution ModeWhere runs executeRemote executes on HCP workers; Local uses local machine; Agent uses private agent
Auto-applyAuto-apply changes after successful planEnable to skip manual apply step
VariablesProvide inputs and environment valuesAdd AWS_SECRET_ACCESS_KEY as an environment variable and mark Sensitive
VCS ConnectionConnect workspace to a repo for VCS-driven runsUse for continuous runs on commits
Run Tasks & TriggersIntegrate checks and downstream runsAdd pre/post-run checks or downstream workspace triggers
Destroy / DeleteWorkspace-level cleanupUse HCP controls or run terraform plan -destroy locally
Destroying infrastructure If you need to destroy resources managed by your local configuration before disconnecting the workspace, run the standard Terraform destroy flow locally:
terraform plan -destroy -out=destroy.tfplan
terraform apply destroy.tfplan
Alternatively, HCP Terraform provides workspace-level options to queue a destroy or delete a workspace from the UI. Next steps
  • Connect your local code by adding the cloud block shown above, then run terraform init and terraform plan to migrate state.
  • Consider connecting a VCS provider to enable version-control-driven runs if you want CI-driven automation.
Links and references That’s it — you’ve created the hcp-demo workspace and reviewed the main settings. You can now connect configuration, add variables, and migrate your local Terraform state into this workspace.

Watch Video