Skip to content

Commit 30ef662

Browse files
committed
Docs tweaks for tfe_workspace_settings and friends
Updating several things I found unclear as a user, plus one thing I found unclear as a fellow maintainer. Also, an important adjustment to some messaging: `r/tfe_workspace_settings` _cannot_ safely be used as a data source, because it interprets absence of each optional argument to explicitly set the workspace's corresponding overwrite to false. This makes me believe we need an overwrites object attribute added to `d/workspace`, but this PR defers that for later.
1 parent 9aeb9d0 commit 30ef662

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

internal/provider/resource_tfe_workspace.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,12 @@ func resourceTFEWorkspaceUpdate(d *schema.ResourceData, meta interface{}) error
598598
}
599599
}
600600

601+
// NOTE: since agent_pool_id and execution_mode are both deprecated on
602+
// tfe_workspace and we want tfe_workspace_settings to be authoritative,
603+
// we must not set the overwrites values to false in the checks below.
604+
// (Actually, I think we don't need to set them to true here either,
605+
// since the API understands an explicit value in an update request to
606+
// also result in an implicit overwrite = true.)
601607
if d.HasChange("agent_pool_id") {
602608
// Need the raw configuration value of the agent_pool_id because when the workspace's execution mode is set
603609
// to default, we can't know for certain what the default value of the agent pool will be. This means we can

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` - **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.
63+
* `execution_mode` - Indicates the [execution mode](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/settings#execution-mode) of the workspace. **Note:** This value might be derived from an organization-level default or set on the workspace itself; see the [`tfe_workspace_settings` resource](tfe_workspace_settings) for details.
6464
* `html_url` - The URL to the browsable HTML overview of the workspace
6565

6666

website/docs/r/organization_default_settings.html.markdown

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: |-
77
88
# tfe_organization_default_settings
99
10-
Primarily, this is used to set the default execution mode of an organization. This setting will be used as the default for all workspaces in the organization.
10+
Primarily, this is used to set the default execution mode of an organization. Settings configured here will be used as the default for all workspaces in the organization, unless they specify their own values with a [`tfe_workspace_settings` resource](workspace_settings.html) (or deprecated attributes on the workspace resource).
1111
1212
## Example Usage
1313
@@ -32,7 +32,9 @@ resource "tfe_organization_default_settings" "org_default" {
3232

3333
resource "tfe_workspace" "my_workspace" {
3434
name = "my-workspace"
35-
# Ensures this workspace will inherit the org defaults
35+
# This workspace will use the org defaults, and will report those defaults as
36+
# the values of its corresponding attributes. Use depends_on to get accurate
37+
# values immediately, and to ensure reliable behavior of tfe_workspace_run.
3638
depends_on = [tfe_organization_default_settings.org_default]
3739
}
3840
```

website/docs/r/workspace.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ 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.
12+
~> **NOTE:** Setting the execution mode and agent pool affinity directly on the workspace is deprecated in favor of using both [tfe_workspace_settings](workspace_settings) and [tfe_organization_default_settings](organization_default_settings), since they allow more precise control and fully support [agent_pool_allowed_workspaces](agent_pool_allowed_workspaces). Use caution when unsetting `execution_mode`, as it now leaves any prior value unmanaged instead of reverting to the old default value of `"remote"`.
1313

1414
~> **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.
1515

website/docs/r/workspace_settings.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: |-
77

88
# tfe_workspace_settings
99

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.
10+
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](organization_default_settings.html). 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.
1111

1212
## Example Usage
1313

@@ -88,7 +88,7 @@ The following arguments are supported:
8888
* `agent_pool_id` - (Optional) The ID of an agent pool to assign to the workspace. Requires `execution_mode`
8989
to be set to `agent`. This value _must not_ be provided if `execution_mode` is set to any other value.
9090
* `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.
91+
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. **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.
9292

9393
## Attributes Reference
9494

0 commit comments

Comments
 (0)