Skip to content

Commit 7200bcc

Browse files
docs: add import examples (#118)
Closes #117.
1 parent 04865bd commit 7200bcc

File tree

9 files changed

+98
-16
lines changed

9 files changed

+98
-16
lines changed

docs/resources/group.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ subcategory: ""
55
description: |-
66
A group on the Coder deployment.
77
Creating groups requires an Enterprise license.
8-
When importing, the ID supplied can be either a group UUID retrieved via the API or <organization-name>/<group-name>.
98
---
109

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

1514
Creating groups requires an Enterprise license.
1615

17-
When importing, the ID supplied can be either a group UUID retrieved via the API or `<organization-name>/<group-name>`.
18-
1916
## Example Usage
2017

2118
```terraform
@@ -62,3 +59,21 @@ resource "coderd_group" "group1" {
6259
### Read-Only
6360

6461
- `id` (String) Group ID.
62+
63+
## Import
64+
65+
Import is supported using the following syntax:
66+
67+
```shell
68+
# The ID supplied can be either a group UUID retrieved via the API
69+
# or a fully qualified name: `<organization-name>/<group-name>`.
70+
$ terraform import coderd_group.example coder/developers
71+
```
72+
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:
73+
74+
```terraform
75+
import {
76+
to = coderd_group.example
77+
id = "coder/developers"
78+
}
79+
```

docs/resources/template.md

+22-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ subcategory: ""
55
description: |-
66
A Coder template.
77
Logs from building template versions can be optionally streamed from the provisioner by setting the TF_LOG environment variable to INFO or higher.
8-
When importing, the ID supplied can be either a template UUID retrieved via the API or <organization-name>/<template-name>.
98
---
109

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

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

17-
When importing, the ID supplied can be either a template UUID retrieved via the API or `<organization-name>/<template-name>`.
18-
1916
## Example Usage
2017

2118
```terraform
@@ -164,3 +161,25 @@ Optional:
164161

165162
- `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.
166163
- `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.
164+
165+
## Import
166+
167+
Import is supported using the following syntax:
168+
169+
```shell
170+
# The ID supplied can be either a template UUID retrieved via the API
171+
# or a fully qualified name: `<organization-name>/<template-name>`.
172+
$ terraform import coderd_template.example coder/dogfood
173+
```
174+
Once imported, you'll need to manually declare in your config:
175+
- The `versions` list, in order to specify the source directories for new versions of the template.
176+
- (Enterprise) The `acl` attribute, in order to specify the users and groups that have access to the template.
177+
178+
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:
179+
180+
```terraform
181+
import {
182+
to = coderd_template.example
183+
id = "coder/dogfood"
184+
}
185+
```

docs/resources/user.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ page_title: "coderd_user Resource - terraform-provider-coderd"
44
subcategory: ""
55
description: |-
66
A user on the Coder deployment.
7-
When importing, the ID supplied can be either a user UUID or a username.
87
---
98

109
# coderd_user (Resource)
1110

1211
A user on the Coder deployment.
1312

14-
When importing, the ID supplied can be either a user UUID or a username.
15-
1613
## Example Usage
1714

1815
```terraform
@@ -65,3 +62,21 @@ resource "coderd_user" "admin" {
6562
### Read-Only
6663

6764
- `id` (String) User ID
65+
66+
## Import
67+
68+
Import is supported using the following syntax:
69+
70+
```shell
71+
# The ID supplied can be either a user UUID retrieved via the API
72+
# or a username.
73+
$ terraform import coderd_user.example developer
74+
```
75+
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:
76+
77+
```terraform
78+
import {
79+
to = coderd_user.example
80+
id = "developer"
81+
}
82+
```
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The ID supplied can be either a group UUID retrieved via the API
2+
# or a fully qualified name: `<organization-name>/<group-name>`.
3+
$ terraform import coderd_group.example coder/developers
4+
```
5+
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:
6+
7+
```terraform
8+
import {
9+
to = coderd_group.example
10+
id = "coder/developers"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# The ID supplied can be either a template UUID retrieved via the API
2+
# or a fully qualified name: `<organization-name>/<template-name>`.
3+
$ terraform import coderd_template.example coder/dogfood
4+
```
5+
Once imported, you'll need to manually declare in your config:
6+
- The `versions` list, in order to specify the source directories for new versions of the template.
7+
- (Enterprise) The `acl` attribute, in order to specify the users and groups that have access to the template.
8+
9+
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:
10+
11+
```terraform
12+
import {
13+
to = coderd_template.example
14+
id = "coder/dogfood"
15+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The ID supplied can be either a user UUID retrieved via the API
2+
# or a username.
3+
$ terraform import coderd_user.example developer
4+
```
5+
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:
6+
7+
```terraform
8+
import {
9+
to = coderd_user.example
10+
id = "developer"
11+
}

internal/provider/group_resource.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ func (r *GroupResource) Metadata(ctx context.Context, req resource.MetadataReque
6262
func (r *GroupResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
6363
resp.Schema = schema.Schema{
6464
MarkdownDescription: "A group on the Coder deployment.\n\n" +
65-
"Creating groups requires an Enterprise license.\n\n" +
66-
"When importing, the ID supplied can be either a group UUID retrieved via the API or `<organization-name>/<group-name>`.",
65+
"Creating groups requires an Enterprise license.",
6766

6867
Attributes: map[string]schema.Attribute{
6968
"id": schema.StringAttribute{

internal/provider/template_resource.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,7 @@ func (r *TemplateResource) Metadata(ctx context.Context, req resource.MetadataRe
243243
func (r *TemplateResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
244244
resp.Schema = schema.Schema{
245245
MarkdownDescription: "A Coder template.\n\nLogs from building template versions can be optionally streamed from the provisioner " +
246-
"by setting the `TF_LOG` environment variable to `INFO` or higher.\n\n" +
247-
"When importing, the ID supplied can be either a template UUID retrieved via the API or `<organization-name>/<template-name>`.",
248-
246+
"by setting the `TF_LOG` environment variable to `INFO` or higher.",
249247
Attributes: map[string]schema.Attribute{
250248
"id": schema.StringAttribute{
251249
MarkdownDescription: "The ID of the template.",

internal/provider/user_resource.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ func (r *UserResource) Metadata(ctx context.Context, req resource.MetadataReques
5656

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

6261
Attributes: map[string]schema.Attribute{
6362
"id": schema.StringAttribute{

0 commit comments

Comments
 (0)