|
| 1 | +--- |
| 2 | +layout: "tfe" |
| 3 | +page_title: "Terraform Enterprise: tfe_workspace_setting" |
| 4 | +description: |- |
| 5 | + Manages workspace settings. |
| 6 | +--- |
| 7 | + |
| 8 | + |
| 9 | +<!-- Please do not edit this file, it is generated. --> |
| 10 | +# tfe_workspace_settings |
| 11 | + |
| 12 | +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. |
| 13 | + |
| 14 | +## Example Usage |
| 15 | + |
| 16 | +Basic usage: |
| 17 | + |
| 18 | +```python |
| 19 | +# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug |
| 20 | +from constructs import Construct |
| 21 | +from cdktf import TerraformStack |
| 22 | +# |
| 23 | +# Provider bindings are generated by running `cdktf get`. |
| 24 | +# See https://cdk.tf/provider-generation for more details. |
| 25 | +# |
| 26 | +from imports.tfe.organization import Organization |
| 27 | +from imports.tfe.workspace import Workspace |
| 28 | +from imports.tfe.workspace_settings import WorkspaceSettings |
| 29 | +class MyConvertedCode(TerraformStack): |
| 30 | + def __init__(self, scope, name): |
| 31 | + super().__init__(scope, name) |
| 32 | + test_organization = Organization(self, "test-organization", |
| 33 | + |
| 34 | + name="my-org-name" |
| 35 | + ) |
| 36 | + test = Workspace(self, "test", |
| 37 | + name="my-workspace-name", |
| 38 | + organization=test_organization.name |
| 39 | + ) |
| 40 | + WorkspaceSettings(self, "test-settings", |
| 41 | + execution_mode="local", |
| 42 | + workspace_id=test.id |
| 43 | + ) |
| 44 | +``` |
| 45 | + |
| 46 | +With `execution_mode` of `agent`: |
| 47 | + |
| 48 | +```python |
| 49 | +# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug |
| 50 | +from constructs import Construct |
| 51 | +from cdktf import TerraformStack |
| 52 | +# |
| 53 | +# Provider bindings are generated by running `cdktf get`. |
| 54 | +# See https://cdk.tf/provider-generation for more details. |
| 55 | +# |
| 56 | +from imports.tfe.agent_pool import AgentPool |
| 57 | +from imports.tfe.agent_pool_allowed_workspaces import AgentPoolAllowedWorkspaces |
| 58 | +from imports.tfe.organization import Organization |
| 59 | +from imports.tfe.workspace import Workspace |
| 60 | +from imports.tfe.workspace_settings import WorkspaceSettings |
| 61 | +class MyConvertedCode(TerraformStack): |
| 62 | + def __init__(self, scope, name): |
| 63 | + super().__init__(scope, name) |
| 64 | + test_organization = Organization(self, "test-organization", |
| 65 | + |
| 66 | + name="my-org-name" |
| 67 | + ) |
| 68 | + test = Workspace(self, "test", |
| 69 | + name="my-workspace-name", |
| 70 | + organization=test_organization.name |
| 71 | + ) |
| 72 | + test_agent_pool = AgentPool(self, "test-agent-pool", |
| 73 | + name="my-agent-pool-name", |
| 74 | + organization=test_organization.name |
| 75 | + ) |
| 76 | + tfe_agent_pool_allowed_workspaces_test = AgentPoolAllowedWorkspaces(self, "test_3", |
| 77 | + agent_pool_id=test_agent_pool.id, |
| 78 | + allowed_workspace_ids=[test.id] |
| 79 | + ) |
| 80 | + # This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match. |
| 81 | + tfe_agent_pool_allowed_workspaces_test.override_logical_id("test") |
| 82 | + WorkspaceSettings(self, "test-settings", |
| 83 | + agent_pool_id=test_agent_pool.id, |
| 84 | + execution_mode="agent", |
| 85 | + workspace_id=test.id |
| 86 | + ) |
| 87 | +``` |
| 88 | + |
| 89 | +This resource may be used as a data source when no optional arguments are defined: |
| 90 | + |
| 91 | +```python |
| 92 | +# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug |
| 93 | +from constructs import Construct |
| 94 | +from cdktf import Token, TerraformOutput, Op, Fn, TerraformStack |
| 95 | +# |
| 96 | +# Provider bindings are generated by running `cdktf get`. |
| 97 | +# See https://cdk.tf/provider-generation for more details. |
| 98 | +# |
| 99 | +from imports.tfe.data_tfe_workspace import DataTfeWorkspace |
| 100 | +from imports.tfe.workspace_settings import WorkspaceSettings |
| 101 | +class MyConvertedCode(TerraformStack): |
| 102 | + def __init__(self, scope, name): |
| 103 | + super().__init__(scope, name) |
| 104 | + test = DataTfeWorkspace(self, "test", |
| 105 | + name="my-workspace-name", |
| 106 | + organization="my-org-name" |
| 107 | + ) |
| 108 | + tfe_workspace_settings_test = WorkspaceSettings(self, "test_1", |
| 109 | + workspace_id=Token.as_string(test.id) |
| 110 | + ) |
| 111 | + # This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match. |
| 112 | + tfe_workspace_settings_test.override_logical_id("test") |
| 113 | + TerraformOutput(self, "workspace-explicit-local-execution", |
| 114 | + value=Fn.alltrue( |
| 115 | + Token.as_any([ |
| 116 | + Op.eq(tfe_workspace_settings_test.execution_mode, "local"), |
| 117 | + Fn.lookup_nested(tfe_workspace_settings_test.overwrites, ["0", "\"execution_mode\"" |
| 118 | + ]) |
| 119 | + ])) |
| 120 | + ) |
| 121 | +``` |
| 122 | + |
| 123 | +## Argument Reference |
| 124 | + |
| 125 | +The following arguments are supported: |
| 126 | + |
| 127 | +* `workspace_id` - (Required) ID of the workspace. |
| 128 | +* `agent_pool_id` - (Optional) The ID of an agent pool to assign to the workspace. Requires `execution_mode` |
| 129 | + to be set to `agent`. This value _must not_ be provided if `execution_mode` is set to any other value. |
| 130 | +* `execution_mode` - (Optional) Which [execution mode](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/settings#execution-mode) |
| 131 | + 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. |
| 132 | + |
| 133 | +## Attributes Reference |
| 134 | + |
| 135 | +In addition to all arguments above, the following attributes are exported: |
| 136 | + |
| 137 | +* `id` - The workspace ID. |
| 138 | +* `overwrites` - Can be used to check whether a setting is currently inheriting its value from another resource. |
| 139 | + - `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) |
| 140 | + - `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) |
| 141 | + |
| 142 | +## Import |
| 143 | + |
| 144 | +Workspaces can be imported; use `<WORKSPACE ID>` or `<ORGANIZATION NAME>/<WORKSPACE NAME>` as the |
| 145 | +import ID. For example: |
| 146 | + |
| 147 | +```shell |
| 148 | +terraform import tfe_workspace_settings.test ws-CH5in3chf8RJjrVd |
| 149 | +``` |
| 150 | + |
| 151 | +```shell |
| 152 | +terraform import tfe_workspace_settings.test my-org-name/my-wkspace-name |
| 153 | +``` |
| 154 | + |
| 155 | +<!-- cache-key: cdktf-0.19.0 input-9b7213e3f3430e82b75a7c71909f07742b81d886b2bb9c0f527258ec71436d66 --> |
0 commit comments