-
Notifications
You must be signed in to change notification settings - Fork 3
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ethanndickson
merged 1 commit into
main
from
08-20-docs_add_examples_for_all_resources_data_sources
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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. | ||
~> 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 = "[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 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
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
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 |
---|---|---|
|
@@ -39,6 +39,7 @@ resource "coderd_user" "audit" { | |
resource "coderd_user" "admin" { | ||
username = "admin" | ||
suspended = true | ||
email = "[email protected]" | ||
} | ||
``` | ||
|
||
|
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
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 = [] | ||
} | ||
} |
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.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.