-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add examples for all resources & data sources
- Loading branch information
1 parent
dfa7472
commit 43b6d91
Showing
20 changed files
with
383 additions
and
17 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
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
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
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
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 |
---|---|---|
|
@@ -3,22 +3,88 @@ | |
page_title: "coderd Provider" | ||
subcategory: "" | ||
description: |- | ||
The coderd provider can be used to manage resources on a Coder deployment. The provider exposes resources and data sources for users, groups, templates, and workspace proxies. | ||
~> Warning | ||
This provider is only compatible with Coder version 2.10.1 https://github.com/coder/coder/releases/tag/v2.10.1 and later. | ||
--- | ||
|
||
# coderd Provider | ||
|
||
The coderd provider can be used to manage resources on a Coder deployment. The provider exposes resources and data sources for users, groups, templates, and workspace proxies. | ||
|
||
~> **Warning** | ||
This provider is only compatible with Coder version [2.10.1](https://github.com/coder/coder/releases/tag/v2.10.1) and later. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
terraform { | ||
required_providers { | ||
coderd = { | ||
source = "coder/coderd" | ||
} | ||
} | ||
} | ||
provider "coderd" { | ||
# `token` and `url` can be populated from environment variables. | ||
# `default_organization_id` can be populated using | ||
# the first organization the session token has access to. | ||
} | ||
data "coderd_organization" "default" { | ||
is_default = true | ||
} | ||
data "coderd_user" "admin" { | ||
username = "admin" | ||
} | ||
resource "coderd_user" "manager" { | ||
username = "Manager" | ||
email = "[email protected]" | ||
} | ||
resource "coderd_group" "bosses" { | ||
name = "group" | ||
members = [ | ||
data.coderd_user.admin.id, | ||
resource.coderd_user.manager.id | ||
] | ||
} | ||
resource "coderd_template" "example" { | ||
name = "example-template" | ||
versions = [{ | ||
directory = "./example-template" | ||
active = true | ||
tf_vars = [{ | ||
name = "image_id" | ||
value = "ami-12345678" | ||
}] | ||
# Version names can be randomly generated if null/omitted | ||
}] | ||
acl = { | ||
groups = [{ | ||
id = data.coderd_organization.default.id | ||
role = "use" | ||
}, | ||
{ | ||
id = resource.coderd_group.bosses.id | ||
role = "admin" | ||
}] | ||
users = [] | ||
} | ||
allow_user_cancel_workspace_jobs = false | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `default_organization_id` (String) Default organization ID to use when creating resources. Defaults to the first organization the token has access to. | ||
- `token` (String) API token for communicating with the deployment. Most resource types require elevated permissions. Defaults to $CODER_SESSION_TOKEN. | ||
- `url` (String) URL to the Coder deployment. Defaults to $CODER_URL. | ||
- `token` (String) API token for communicating with the deployment. Most resource types require elevated permissions. Defaults to `$CODER_SESSION_TOKEN`. | ||
- `url` (String) URL to the Coder deployment. Defaults to `$CODER_URL`. |
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
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
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 |
---|---|---|
|
@@ -39,6 +39,7 @@ resource "coderd_user" "audit" { | |
resource "coderd_user" "admin" { | ||
username = "admin" | ||
suspended = true | ||
email = "[email protected]" | ||
} | ||
``` | ||
|
||
|
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Get a group on the provider default organization by `id` | ||
data "coderd_group" "employees" { | ||
id = "abcd-efg-hijk" | ||
} | ||
|
||
// Get a group on the provider default organization by `name` + `organization_id` | ||
data "coderd_group" "bosses" { | ||
name = "bosses" | ||
} | ||
|
||
// Use them to apply ACL to a template | ||
resource "coderd_template" "example" { | ||
name = "example-template" | ||
versions = [/* ... */] | ||
acl = { | ||
groups = [ | ||
{ | ||
id = data.coderd_group.employees.id | ||
role = "use" | ||
}, | ||
{ | ||
id = data.coderd_group.bosses.id | ||
role = "admin" | ||
} | ||
] | ||
users = [] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Get the default (first) organization for the coder deployment | ||
data "coderd_organization" "default" { | ||
is_default = true | ||
} | ||
|
||
// Get another organization by `id` | ||
data "coderd_organization" "example" { | ||
id = "abcd-efg-hijk" | ||
} | ||
|
||
data "coderd_organization" "example2" { | ||
name = "example-organization-2" | ||
} | ||
|
||
// Create a group on a specific organization | ||
resource "coderd_group" "example" { | ||
name = "example-group" | ||
organization_id = data.coderd_organization.default.id | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Get a template on the provider's default organization by `id` | ||
data "coderd_template" "example-template" { | ||
id = "abcd-efg-hijk" | ||
} | ||
|
||
// Get a template on the provider's default organization by `name` | ||
data "coderd_template" "example-template2" { | ||
name = "example-template-2" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Get a user on the Coder deployment by `id` | ||
data "coderd_user" "manager" { | ||
id = "abcd-efg-hijk" | ||
} | ||
|
||
// Get a user on the Coder deployment by `username` | ||
data "coderd_user" "admin" { | ||
username = "admin" | ||
} | ||
|
||
|
||
// Use them to create a group | ||
resource "coderd_group" "bosses" { | ||
name = "group" | ||
members = [ | ||
data.coderd_user.admin.id, | ||
data.coderd_user.manager.id | ||
] | ||
} |
Oops, something went wrong.