capabilities.work

Provision a Workspace with Initial Variables

A 5-step recipe with Terraform. We can help you get access.

Recipe · 5 steps

Provision a Workspace with Initial Variables

Create a new HCP Terraform workspace and seed it with variables.

  1. Read the organization to confirm the bearer token can reach it and that the plan is active before creating any billable resources inside it.
  2. Create the workspace inside the verified organization using the supplied name, execution mode, and Terraform version.
  3. Attach the initial Terraform variable to the new workspace so the first run has the input it needs.
  4. Attach the initial environment variable, typically a provider credential or region hint, marking it sensitive when requested.
  5. Read the workspace back to confirm it exists, is unlocked, and settled with the execution mode that was requested.
What you'll need to have ready
  • organizationName: The HCP Terraform organization name that will own the workspace.
  • workspaceName: The name for the new workspace (e.g. "networking-production").
  • workspaceDescription: A human readable description for the workspace.
  • executionMode: How runs execute for this workspace - remote, local, or agent.
  • terraformVersion: The Terraform version the workspace should pin to (e.g. "1.9.5").
  • autoApply: Whether plans apply automatically without confirmation.
  • terraformVariableKey: The key of the initial Terraform variable (e.g. "region").
  • terraformVariableValue: The value of the initial Terraform variable (e.g. "us-east-1").
  • environmentVariableKey: The key of the initial environment variable (e.g. "AWS_REGION").
  • environmentVariableValue: The value of the initial environment variable.
  • environmentVariableSensitive: Whether the environment variable value should be write-only.
For your developer

Arazzo workflow terraform:provision-workspace, 5 operations: GetOrganization → CreateWorkspace → CreateWorkspaceVariable → CreateWorkspaceVariable → GetWorkspace. Specs on APIs.io.