Skip to content

Commit 6f67879

Browse files
committed
Improve agent_pool_allowed_workspaces docs
1 parent 32354dc commit 6f67879

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

website/docs/r/agent_pool_allowed_workspaces.html.markdown

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,23 @@ description: |-
77

88
# tfe_agent_pool_allowed_workspaces
99

10-
Adds and removes allowed workspaces on an agent pool
10+
Adds and removes allowed workspaces on an agent pool.
1111

1212
~> **NOTE:** This resource requires using the provider with Terraform Cloud and a Terraform Cloud
1313
for Business account.
1414
[Learn more about Terraform Cloud pricing here](https://www.hashicorp.com/products/terraform/pricing).
1515

1616
## Example Usage
1717

18-
Basic usage:
18+
In this example, the agent pool and workspace are connected through other resources that manage the agent pool permissions as well as the workspace execution mode. Notice that the `tfe_workspace_settings` uses the agent pool reference found in `tfe_agent_pool_allowed_workspaces` in order to create the permission to use the agent pool before assigning it.
1919

2020
```hcl
2121
resource "tfe_organization" "test-organization" {
2222
name = "my-org-name"
2323
2424
}
2525
26+
// Ensure workspace and agent pool are create first
2627
resource "tfe_workspace" "test-workspace" {
2728
name = "my-workspace-name"
2829
organization = tfe_organization.test-organization.name
@@ -34,9 +35,18 @@ resource "tfe_agent_pool" "test-agent-pool" {
3435
organization_scoped = false
3536
}
3637
37-
resource "tfe_agent_pool_allowed_workspaces" "test-allowed-workspaces" {
38+
// Ensure permissions are assigned second
39+
resource "tfe_agent_pool_allowed_workspaces" "allowed" {
3840
agent_pool_id = tfe_agent_pool.test-agent-pool.id
39-
allowed_workspace_ids = [tfe_workspace.test-workspace.id]
41+
allowed_workspace_ids = [for key, value in tfe_workspace.test.*.id : value]
42+
}
43+
44+
// Lastly, ensure the workspace agent execution is assigned last by
45+
// referencing allowed_workspaces
46+
resource "tfe_workspace_settings" "test-workspace-settings" {
47+
workspace_id = tfe_workspace.test-workspace.id
48+
execution_mode = "agent"
49+
agent_pool_id = tfe_agent_pool_allowed_workspaces.allowed.id
4050
}
4151
```
4252

@@ -55,4 +65,3 @@ A resource can be imported; use `<AGENT POOL ID>` as the import ID. For example:
5565
```shell
5666
terraform import tfe_agent_pool_allowed_workspaces.foobar apool-rW0KoLSlnuNb5adB
5767
```
58-

0 commit comments

Comments
 (0)