tfe_workspace_settings

Manages or reads execution mode and agent pool settings for a workspace. This also interacts with the organization's default values for several settings, which can be managed with tfe_organization_default_settings. If other resources need to identify whether a setting is a default or an explicit value set for the workspace, you can refer to the read-only overwrites argument.

Example Usage

Basic usage:

resource "tfe_organization" "test-organization" {
  name  = "my-org-name"
  email = "admin@company.com"
}

resource "tfe_workspace" "test" {
  name         = "my-workspace-name"
  organization = tfe_organization.test-organization.name
}

resource "tfe_workspace_settings" "test-settings" {
  workspace_id   = tfe_workspace.test.id
  execution_mode = "local"
}

With execution_mode of agent:

resource "tfe_organization" "test-organization" {
  name  = "my-org-name"
  email = "admin@company.com"
}

resource "tfe_agent_pool" "test-agent-pool" {
  name         = "my-agent-pool-name"
  organization = tfe_organization.test-organization.name
}

resource "tfe_agent_pool_allowed_workspaces" "test" {
  agent_pool_id         = tfe_agent_pool.test-agent-pool.id
  allowed_workspace_ids = [tfe_workspace.test.id]
}

resource "tfe_workspace" "test" {
  name           = "my-workspace-name"
  organization   = tfe_organization.test-organization.name
}

resource "tfe_workspace_settings" "test-settings" {
  workspace_id   = tfe_workspace.test.id
  agent_pool_id  = tfe_agent_pool_allowed_workspaces.test.agent_pool_id
  execution_mode = "agent"
}

This resource may be used as a data source when no optional arguments are defined:

data "tfe_workspace" "test" {
  name           = "my-workspace-name"
  organization   = "my-org-name"
}

resource "tfe_workspace_settings" "test" {
  workspace_id   = data.tfe_workspace.test.id
}

output "workspace-explicit-local-execution" {
  value = alltrue([
    tfe_workspace_settings.test.execution_mode == "local",
    tfe_workspace_settings.test.overwrites[0]["execution_mode"]
  ])
}

Argument Reference

The following arguments are supported:

Attributes Reference

In addition to all arguments above, the following attributes are exported:

Import

Workspaces can be imported; use <WORKSPACE ID> or <ORGANIZATION NAME>/<WORKSPACE NAME> as the import ID. For example:

terraform import tfe_workspace_settings.test ws-CH5in3chf8RJjrVd
terraform import tfe_workspace_settings.test my-org-name/my-wkspace-name