- Notifications
You must be signed in to change notification settings - Fork3
docs: add examples for all resources & data sources#78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
ethanndickson merged 1 commit intomainfrom08-20-docs_add_examples_for_all_resources_data_sourcesAug 22, 2024
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
31 changes: 31 additions & 0 deletionsdocs/data-sources/group.md
This file contains hidden or 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
25 changes: 24 additions & 1 deletiondocs/data-sources/organization.md
This file contains hidden or 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
24 changes: 24 additions & 0 deletionsdocs/data-sources/template.md
This file contains hidden or 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
24 changes: 23 additions & 1 deletiondocs/data-sources/user.md
This file contains hidden or 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
69 changes: 67 additions & 2 deletionsdocs/index.md
This file contains hidden or 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,87 @@ | ||
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. | ||
ethanndickson marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
~> 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" { | ||
url = "coder.example.com" | ||
token = "****" | ||
} | ||
data "coderd_organization" "default" { | ||
is_default = true | ||
} | ||
data "coderd_user" "admin" { | ||
username = "admin" | ||
} | ||
resource "coderd_user" "manager" { | ||
username = "Manager" | ||
email = "manager@example.com" | ||
} | ||
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`. |
9 changes: 6 additions & 3 deletionsdocs/resources/group.md
This file contains hidden or 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
12 changes: 9 additions & 3 deletionsdocs/resources/template.md
This file contains hidden or 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
1 change: 1 addition & 0 deletionsdocs/resources/user.md
This file contains hidden or 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
33 changes: 32 additions & 1 deletiondocs/resources/workspace_proxy.md
This file contains hidden or 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
28 changes: 28 additions & 0 deletionsexamples/data-sources/coderd_group/data-source.tf
This file contains hidden or 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 = [] | ||
} | ||
} |
20 changes: 20 additions & 0 deletionsexamples/data-sources/coderd_organization/data-source.tf
This file contains hidden or 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,20 @@ | ||
// 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" | ||
} | ||
// Or get by name | ||
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.example.id | ||
} |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.