-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1191 from hashicorp/IPL-5516-unable-to-second-app…
…ly-destroy-with-tfe-workspace-settings-with-tfe-provider-0-51-0 Improve tfe_agent_pool_allowed_workspaces docs
- Loading branch information
Showing
1 changed file
with
14 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,22 +7,23 @@ description: |- | |
|
||
# tfe_agent_pool_allowed_workspaces | ||
|
||
Adds and removes allowed workspaces on an agent pool | ||
Adds and removes allowed workspaces on an agent pool. | ||
|
||
~> **NOTE:** This resource requires using the provider with Terraform Cloud and a Terraform Cloud | ||
for Business account. | ||
[Learn more about Terraform Cloud pricing here](https://www.hashicorp.com/products/terraform/pricing). | ||
|
||
## Example Usage | ||
|
||
Basic usage: | ||
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. | ||
|
||
```hcl | ||
resource "tfe_organization" "test-organization" { | ||
name = "my-org-name" | ||
email = "[email protected]" | ||
} | ||
// Ensure workspace and agent pool are create first | ||
resource "tfe_workspace" "test-workspace" { | ||
name = "my-workspace-name" | ||
organization = tfe_organization.test-organization.name | ||
|
@@ -34,9 +35,18 @@ resource "tfe_agent_pool" "test-agent-pool" { | |
organization_scoped = false | ||
} | ||
resource "tfe_agent_pool_allowed_workspaces" "test-allowed-workspaces" { | ||
// Ensure permissions are assigned second | ||
resource "tfe_agent_pool_allowed_workspaces" "allowed" { | ||
agent_pool_id = tfe_agent_pool.test-agent-pool.id | ||
allowed_workspace_ids = [tfe_workspace.test-workspace.id] | ||
allowed_workspace_ids = [for key, value in tfe_workspace.test.*.id : value] | ||
} | ||
// Lastly, ensure the workspace agent execution is assigned last by | ||
// referencing allowed_workspaces | ||
resource "tfe_workspace_settings" "test-workspace-settings" { | ||
workspace_id = tfe_workspace.test-workspace.id | ||
execution_mode = "agent" | ||
agent_pool_id = tfe_agent_pool_allowed_workspaces.allowed.id | ||
} | ||
``` | ||
|
||
|
@@ -55,4 +65,3 @@ A resource can be imported; use `<AGENT POOL ID>` as the import ID. For example: | |
```shell | ||
terraform import tfe_agent_pool_allowed_workspaces.foobar apool-rW0KoLSlnuNb5adB | ||
``` | ||
|