Skip to content

docs: add import examples #118

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
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions docs/resources/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ subcategory: ""
description: |-
A group on the Coder deployment.
Creating groups requires an Enterprise license.
When importing, the ID supplied can be either a group UUID retrieved via the API or <organization-name>/<group-name>.
---

# coderd_group (Resource)
Expand All @@ -14,8 +13,6 @@ A group on the Coder deployment.

Creating groups requires an Enterprise license.

When importing, the ID supplied can be either a group UUID retrieved via the API or `<organization-name>/<group-name>`.

## Example Usage

```terraform
Expand Down Expand Up @@ -62,3 +59,21 @@ resource "coderd_group" "group1" {
### Read-Only

- `id` (String) Group ID.

## Import

Import is supported using the following syntax:

```shell
# The ID supplied can be either a group UUID retrieved via the API
# or a fully qualified name: `<organization-name>/<group-name>`.
$ terraform import coderd_group.example coder/developers
```
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:

```terraform
import {
to = coderd_group.example
id = "coder/developers"
}
```
25 changes: 22 additions & 3 deletions docs/resources/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ subcategory: ""
description: |-
A Coder template.
Logs from building template versions can be optionally streamed from the provisioner by setting the TF_LOG environment variable to INFO or higher.
When importing, the ID supplied can be either a template UUID retrieved via the API or <organization-name>/<template-name>.
---

# coderd_template (Resource)
Expand All @@ -14,8 +13,6 @@ A Coder template.

Logs from building template versions can be optionally streamed from the provisioner by setting the `TF_LOG` environment variable to `INFO` or higher.

When importing, the ID supplied can be either a template UUID retrieved via the API or `<organization-name>/<template-name>`.

## Example Usage

```terraform
Expand Down Expand Up @@ -164,3 +161,25 @@ Optional:

- `days_of_week` (Set of String) List of days of the week on which restarts are required. Restarts happen within the user's quiet hours (in their configured timezone). If no days are specified, restarts are not required.
- `weeks` (Number) Weeks is the number of weeks between required restarts. Weeks are synced across all workspaces (and Coder deployments) using modulo math on a hardcoded epoch week of January 2nd, 2023 (the first Monday of 2023). Values of 0 or 1 indicate weekly restarts. Values of 2 indicate fortnightly restarts, etc.

## Import

Import is supported using the following syntax:

```shell
# The ID supplied can be either a template UUID retrieved via the API
# or a fully qualified name: `<organization-name>/<template-name>`.
$ terraform import coderd_template.example coder/dogfood
```
Once imported, you'll need to manually declare in your config:
- The `versions` list, in order to specify the source directories for new versions of the template.
- (Enterprise) The `acl` attribute, in order to specify the users and groups that have access to the template.

Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:

```terraform
import {
to = coderd_template.example
id = "coder/dogfood"
}
```
21 changes: 18 additions & 3 deletions docs/resources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ page_title: "coderd_user Resource - terraform-provider-coderd"
subcategory: ""
description: |-
A user on the Coder deployment.
When importing, the ID supplied can be either a user UUID or a username.
---

# coderd_user (Resource)

A user on the Coder deployment.

When importing, the ID supplied can be either a user UUID or a username.

## Example Usage

```terraform
Expand Down Expand Up @@ -65,3 +62,21 @@ resource "coderd_user" "admin" {
### Read-Only

- `id` (String) User ID

## Import

Import is supported using the following syntax:

```shell
# The ID supplied can be either a user UUID retrieved via the API
# or a username.
$ terraform import coderd_user.example developer
```
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:

```terraform
import {
to = coderd_user.example
id = "developer"
}
```
11 changes: 11 additions & 0 deletions examples/resources/coderd_group/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# The ID supplied can be either a group UUID retrieved via the API
# or a fully qualified name: `<organization-name>/<group-name>`.
$ terraform import coderd_group.example coder/developers
```
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:

```terraform
import {
to = coderd_group.example
id = "coder/developers"
}
15 changes: 15 additions & 0 deletions examples/resources/coderd_template/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# The ID supplied can be either a template UUID retrieved via the API
# or a fully qualified name: `<organization-name>/<template-name>`.
$ terraform import coderd_template.example coder/dogfood
```
Once imported, you'll need to manually declare in your config:
- The `versions` list, in order to specify the source directories for new versions of the template.
- (Enterprise) The `acl` attribute, in order to specify the users and groups that have access to the template.

Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:

```terraform
import {
to = coderd_template.example
id = "coder/dogfood"
}
11 changes: 11 additions & 0 deletions examples/resources/coderd_user/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# The ID supplied can be either a user UUID retrieved via the API
# or a username.
$ terraform import coderd_user.example developer
```
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:

```terraform
import {
to = coderd_user.example
id = "developer"
}
3 changes: 1 addition & 2 deletions internal/provider/group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ func (r *GroupResource) Metadata(ctx context.Context, req resource.MetadataReque
func (r *GroupResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "A group on the Coder deployment.\n\n" +
"Creating groups requires an Enterprise license.\n\n" +
"When importing, the ID supplied can be either a group UUID retrieved via the API or `<organization-name>/<group-name>`.",
"Creating groups requires an Enterprise license.",

Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Expand Down
4 changes: 1 addition & 3 deletions internal/provider/template_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ func (r *TemplateResource) Metadata(ctx context.Context, req resource.MetadataRe
func (r *TemplateResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "A Coder template.\n\nLogs from building template versions can be optionally streamed from the provisioner " +
"by setting the `TF_LOG` environment variable to `INFO` or higher.\n\n" +
"When importing, the ID supplied can be either a template UUID retrieved via the API or `<organization-name>/<template-name>`.",

"by setting the `TF_LOG` environment variable to `INFO` or higher.",
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
MarkdownDescription: "The ID of the template.",
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/user_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ func (r *UserResource) Metadata(ctx context.Context, req resource.MetadataReques

func (r *UserResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "A user on the Coder deployment.\n\n" +
"When importing, the ID supplied can be either a user UUID or a username.",
MarkdownDescription: "A user on the Coder deployment.",

Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Expand Down
Loading