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.
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"]
])
}
The following arguments are supported:
workspace_id
- (Required) ID of the workspace.agent_pool_id
- (Optional) The ID of an agent pool to assign to the workspace. Requires execution_mode
to be set to agent
. This value _must not_ be provided if execution_mode
is set to any other value.execution_mode
- (Optional) Which execution mode
to use. Using HCP Terraform, valid values are remote
, local
or agent
. Using Terraform Enterprise, only remote
and local
execution modes are valid. When set to local
, the workspace will be used for state storage only. Important: If you omit this attribute, the resource configures the workspace to use your organization's default execution mode (which in turn defaults to remote
), removing any explicit value that might have previously been set for the workspace.In addition to all arguments above, the following attributes are exported:
id
- The workspace ID.overwrites
- Can be used to check whether a setting is currently inheriting its value from another resource.
execution_mode
- Set to true
if the execution mode of the workspace is being determined by the setting on the workspace itself. It will be false
if the execution mode is inherited from another resource (e.g. the organization's default execution mode)agent_pool
- Set to true
if the agent pool of the workspace is being determined by the setting on the workspace itself. It will be false
if the agent pool is inherited from another resource (e.g. the organization's default agent pool)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