Skip to main content

Create a workspace

Last updated on

A workspace is a named environment that stores Terraform configurations, variables, states, and other resources necessary to manage infrastructure. Each workspace is mapped to a single state, and you can define a single Terraform configuration with multiple workspaces to enforce the same desired configuration across independent lifecycles.


Before you begin

  • IaCM module access: Your Harness account must have the IaCM module enabled.
  • Workspace permissions: You need Create or Edit permissions on workspaces. Go to Workspace RBAC to configure roles.
  • Git repository: A Git repository (GitHub, GitLab, Bitbucket, or Harness Code) containing your Terraform or OpenTofu configuration.
  • Cloud provider connector: A configured connector for your cloud provider or backend system. Go to Connectors to set one up.

Workspace statuses

A workspace can have one of the following statuses:

  • Active: Successfully deployed and running.
  • Inactive: Successfully destroyed or was not provisioned.
  • Drifted: Drift was detected.
  • Provisioning: Currently being provisioned.
  • Destroying: Currently being destroyed.
  • Failed: Errors were encountered during provisioning or destroying.
  • Apply_Needed: Apply is required to bring the infrastructure in sync with the workspace configuration.
  • Unknown: Changes were made outside the product.

Go to Workspace statuses to filter workspaces by status.


Create a new workspace


If you need to use either environment or Terraform variables during execution, select the Variables tab to define the variables.

  • Environment Variables: can be either String, Secret, or a reference to another variable using a JEXL expression (it can be in the same or a different workspace or from the pipeline).
  • Terraform Variables: can be provided in the following ways:
  • Inline: you can define Terraform variables within the workspace. Variables can be either String, hcl, Secret, or a reference to another variable, using a JEXL expression (can be in the same or a different workspace, or from the pipeline).
  • From Git Repo (Implicit): you can store .tfvar files in the same folder as the Terraform code for the workspace.
  • From Git Repo (Explicit): you can define a specific folder for .tfvar files (which can be different from the Terraform code's location). These files can be in the same or different repository as the Terraform code.
Tfvar JEXL support

JEXL expressions cannot be used to reference tfvar files.

The values defined inline with the workspace take precedence over the git configuration.

Workspace variables


Clone a workspace

Harness supports workspace cloning for quick setup of new workspaces with the same or similar configuration as existing workspaces.


Workspace templates

Create reusable workspace templates to standardize your workspace configurations across projects. Go to Workspace templates to learn how to create and manage workspace templates.


Next steps

Once you have created your workspace by creating a new workspace from scratch, cloning, or using a template, you can provision it to apply your OpenTofu or Terraform state.