Skip to content

Commit 8363b46

Browse files
committed
Document tfe_workspace_settings
1 parent 04182e5 commit 8363b46

File tree

3 files changed

+119
-6
lines changed

3 files changed

+119
-6
lines changed

website/docs/d/workspace.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ In addition to all arguments above, the following attributes are exported:
6060
* `trigger_patterns` - List of [glob patterns](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/settings/vcs#glob-patterns-for-automatic-run-triggering) that describe the files Terraform Cloud monitors for changes. Trigger patterns are always appended to the root directory of the repository.
6161
* `vcs_repo` - Settings for the workspace's VCS repository.
6262
* `working_directory` - A relative path that Terraform will execute within.
63-
* `execution_mode` - Indicates the [execution mode](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/settings#execution-mode) of the workspace. Possible values include `remote`, `local`, or `agent`.
63+
* `execution_mode` - **Deprecated** Indicates the [execution mode](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/settings#execution-mode) of the workspace. Use the `tfe_workspace_settings` resource instead.
6464
* `html_url` - The URL to the browsable HTML overview of the workspace
6565

6666

website/docs/r/workspace.html.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ description: |-
99

1010
Provides a workspace resource.
1111

12+
~> **NOTE:** Setting the execution mode and agent pool affinity directly on the workspace has been deprecated in favor of using both [tfe_workspace_settings](workspace_settings) and [tfe_organization_default_settings](organization_default_settings). Use caution when unsetting `execution_mode` because the default value `"remote"` is no longer applied when the `execution_mode` is unset.
13+
1214
~> **NOTE:** Using `global_remote_state` or `remote_state_consumer_ids` requires using the provider with Terraform Cloud or an instance of Terraform Enterprise at least as recent as v202104-1.
1315

1416
## Example Usage
@@ -54,22 +56,20 @@ resource "tfe_workspace" "parent" {
5456
oauth_token_id = tfe_oauth_client.test.oauth_token_id
5557
}
5658
}
59+
```
5760

5861
## Argument Reference
5962

6063
The following arguments are supported:
6164

6265
* `name` - (Required) Name of the workspace.
63-
* `agent_pool_id` - (Optional) **Deprecated** The ID of an agent pool to assign to the workspace. Requires `execution_mode`
64-
to be set to `agent`. This value _must not_ be provided if `execution_mode` is set to any other value or if `operations` is
65-
provided.
66+
* `agent_pool_id` - (Optional) **Deprecated** The ID of an agent pool to assign to the workspace. Use [tfe_workspace_settings](workspace_settings) instead.
6667
* `allow_destroy_plan` - (Optional) Whether destroy plans can be queued on the workspace.
6768
* `assessments_enabled` - (Optional) Whether to regularly run health assessments such as drift detection on the workspace. Defaults to `false`.
6869
* `auto_apply` - (Optional) Whether to automatically apply changes when a Terraform plan is successful. Defaults to `false`.
6970
* `auto_apply_run_trigger` - (Optional) Whether to automatically apply changes for runs that were created by run triggers from another workspace. Defaults to `false`.
7071
* `description` - (Optional) A description for the workspace.
71-
* `execution_mode` - (Optional) **Deprecated** Which [execution mode](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/settings#execution-mode)
72-
to use. Using Terraform Cloud, 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. This value _must not_ be provided if `operations` is provided.
72+
* `execution_mode` - (Optional) **Deprecated** Which [execution mode](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/settings#execution-mode) to use. Use [tfe_workspace_settings](workspace_settings) instead.
7373
* `file_triggers_enabled` - (Optional) Whether to filter runs based on the changed files
7474
in a VCS push. Defaults to `true`. If enabled, the working directory and
7575
trigger prefixes describe a set of paths which must contain changes for a
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
layout: "tfe"
3+
page_title: "Terraform Enterprise: tfe_workspace_setting"
4+
description: |-
5+
Manages workspace settings.
6+
---
7+
8+
# tfe_workspace_settings
9+
10+
Manages or reads execution mode and agent pool settings for a workspace. If [tfe_organization_default_settings](organization_default_settings.html) are used, those settings may be read using a combination of the read-only `overwrites` argument and the setting itself.
11+
12+
## Example Usage
13+
14+
Basic usage:
15+
16+
```hcl
17+
resource "tfe_organization" "test-organization" {
18+
name = "my-org-name"
19+
20+
}
21+
22+
resource "tfe_workspace" "test" {
23+
name = "my-workspace-name"
24+
organization = tfe_organization.test-organization.name
25+
}
26+
27+
resource "tfe_workspace_settings" "test-settings" {
28+
workspace_id = tfe_workspace.test.id
29+
execution_mode = "local"
30+
}
31+
```
32+
33+
With `execution_mode` of `agent`:
34+
35+
```hcl
36+
resource "tfe_organization" "test-organization" {
37+
name = "my-org-name"
38+
39+
}
40+
41+
resource "tfe_agent_pool" "test-agent-pool" {
42+
name = "my-agent-pool-name"
43+
organization = tfe_organization.test-organization.name
44+
}
45+
46+
resource "tfe_agent_pool_allowed_workspaces" "test" {
47+
agent_pool_id = tfe_agent_pool.test-agent-pool.id
48+
allowed_workspace_ids = [tfe_workspace.test.id]
49+
}
50+
51+
resource "tfe_workspace" "test" {
52+
name = "my-workspace-name"
53+
organization = tfe_organization.test-organization.name
54+
}
55+
56+
resource "tfe_workspace_settings" "test-settings" {
57+
workspace_id = tfe_workspace.test.id
58+
agent_pool_id = tfe_agent_pool.test-agent-pool.id
59+
execution_mode = "agent"
60+
}
61+
```
62+
63+
This resource may be used as a data source when no optional arguments are defined:
64+
65+
```hcl
66+
data "tfe_workspace" "test" {
67+
name = "my-workspace-name"
68+
organization = "my-org-name"
69+
}
70+
71+
resource "tfe_workspace_settings" "test" {
72+
workspace_id = data.tfe_workspace.test.id
73+
}
74+
75+
output "workspace-explicit-local-execution" {
76+
value = alltrue([
77+
tfe_workspace_settings.test.execution_mode == "local",
78+
tfe_workspace_settings.test.overwrites[0]["execution_mode"]
79+
])
80+
}
81+
```
82+
83+
## Argument Reference
84+
85+
The following arguments are supported:
86+
87+
* `workspace_id` - (Required) ID of the workspace.
88+
* `agent_pool_id` - (Optional) The ID of an agent pool to assign to the workspace. Requires `execution_mode`
89+
to be set to `agent`. This value _must not_ be provided if `execution_mode` is set to any other value.
90+
* `execution_mode` - (Optional) Which [execution mode](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/settings#execution-mode)
91+
to use. Using Terraform Cloud, valid values are `remote`, `local` or `agent`. Defaults your organization's default execution mode, or `remote` if no organization default is set. Using Terraform Enterprise, only `remote` and `local` execution modes are valid. When set to `local`, the workspace will be used for state storage only.
92+
93+
## Attributes Reference
94+
95+
In addition to all arguments above, the following attributes are exported:
96+
97+
* `id` - The workspace ID.
98+
* `overwrites` - Can be used to check whether a setting is currently inheriting its value from another resource.
99+
- `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)
100+
- `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)
101+
102+
## Import
103+
104+
Workspaces can be imported; use `<WORKSPACE ID>` or `<ORGANIZATION NAME>/<WORKSPACE NAME>` as the
105+
import ID. For example:
106+
107+
```shell
108+
terraform import tfe_workspace_settings.test ws-CH5in3chf8RJjrVd
109+
```
110+
111+
```shell
112+
terraform import tfe_workspace_settings.test my-org-name/my-wkspace-name
113+
```

0 commit comments

Comments
 (0)