Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0fc1112

Browse files
authoredNov 26, 2024··
docs: v1 to v2 upgrade guide (#259)
1 parent 493a0f1 commit 0fc1112

File tree

5 files changed

+213
-3
lines changed

5 files changed

+213
-3
lines changed
 

‎docs/guides/version-2-upgrade.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
page_title: "Terraform Coder Provider Version 2 Upgrade Guide"
3+
---
4+
5+
# Terraform Coder Provider Version 2 Upgrade Guide
6+
7+
Version 2.0.0 of the Coder provider for Terraform is a major release that introduces some changes that you will need to consider when upgrading.
8+
This guide is intended to help with the process, and focuses only on the changes from version 1.X to version 2.0.0.
9+
10+
!> Using Version 2.0.0 of the Coder provider requires Coder Server version [`2.18.0`](https://github.com/coder/coder/releases/tag/v2.18.0) or later.
11+
12+
Upgrade topics:
13+
14+
- [Provider Version Configuration](#provider-version-configuration)
15+
- [Provider Arguments](#provider-arguments)
16+
- [Data Source: coder_git_auth --> coder_external_auth](#data-source-coder_git_auth)
17+
- [Data Source: coder_workspace](#data-source-coder_workspace)
18+
19+
## Provider Version Configuration
20+
21+
-> Before upgrading to version 2.0.0, please first upgrade to the most recent 1.X version and ensure that your environment successfully runs [`terraform plan`](https://developer.hashicorp.com/terraform/cli/commands/plan) without unexpected changes or deprecation notices.
22+
23+
We highly recommend using [version constraints](https://developer.hashicorp.com/terraform/language/providers/requirements#version-constraints) when configuring Terraform providers.
24+
25+
26+
For example, given the previous configuration:
27+
28+
```terraform
29+
terraform {
30+
required_providers {
31+
coder = {
32+
source = "coder/coder"
33+
version = "~> 1.0.0"
34+
}
35+
}
36+
}
37+
38+
provider "coder" {
39+
feature_use_managed_variables = true
40+
}
41+
```
42+
43+
Update to the latest 2.X version:
44+
45+
```terraform
46+
terraform {
47+
required_providers {
48+
coder = {
49+
source = "coder/coder"
50+
version = "~> 2.0.0"
51+
}
52+
}
53+
}
54+
55+
provider "coder" {}
56+
```
57+
58+
## Provider Arguments
59+
60+
Version 2.0.0 removes the [`feature_use_managed_variables`](https://registry.terraform.io/providers/coder/coder/1.0.4/docs#feature_use_managed_variables-1) argument from the `provider` block.
61+
62+
63+
## Data Source: [`coder_git_auth`](https://registry.terraform.io/providers/coder/coder/1.0.4/docs/data-sources/git_auth)
64+
65+
If you are using this data source, you must replace it with the [`coder_external_auth`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/external_auth) data source. The `coder_external_auth` data source is a more generic data source that can be used to create any external authentication provider which supports OAuth2.
66+
67+
For example, given the previous configuration:
68+
69+
```terraform
70+
data "coder_git_auth" "example" {
71+
id = "example"
72+
}
73+
```
74+
75+
Update to the new data source:
76+
77+
```terraform
78+
data "coder_external_auth" "example" {
79+
id = "example"
80+
}
81+
```
82+
83+
## Data Source: [`coder_workspace`](https://registry.terraform.io/providers/coder/coder/1.0.4/docs/data-sources/workspace)
84+
85+
If you are using the `owner` properties of the `coder_workspace` data source, you must remove them and use the [`coder_workspace_owner`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner) data source instead. The `coder_workspace_owner` data source provides additional properties of the workspace owner.
86+
87+
Update your Terraform configuration to use the `coder_workspace_owner` data source instead and update the following attributes:
88+
89+
```terraform
90+
data "coder_workspace_owner" "me" {}
91+
```
92+
93+
- Remove `owner_id` attribute. Use [`data.coder_workspace_owner.me.id`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#id) instead.
94+
- Remove `owner` attribute. Use [`data.coder_workspace_owner.me.name`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#name) instead.
95+
- Remove `owner_name` attribute. Use [`data.coder_workspace_owner.me.full_name`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#full_name) instead.
96+
- Remove `owner_email` attribute. Use [`data.coder_workspace_owner.me.email`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#email) instead.
97+
- Remove `owner_groups` attribute. Use [`data.coder_workspace_owner.me.groups`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#groups) instead.
98+
- Remove `owner_oidc_access_token` attribute. Use [`data.coder_workspace_owner.me.oidc_access_token`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#oidc_access_token) instead.
99+
- Remove `owner_session_token` attribute. Use [`data.coder_workspace_owner.me.session_token`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#session_token) instead.
100+
101+
->While we do not anticipate these changes to affect existing resources, we strongly advice reviewing the plan produced by Terraform to ensure no resources are accidentally removed or altered in an undesired way. If you encounter any unexpected behavior, please report it by opening a GitHub [issue](https://github.com/coder/terraform-provider-coder/issues).

‎docs/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ description: |-
88

99
# Coder Provider
1010

11-
Terraform provider for managing Coder [templates](https://coder.com/docs/templates), which are the underlying infrastructure for Coder [workspaces](https://coder.com/docs/workspaces).
11+
Terraform provider for managing Coder [templates](https://coder.com/docs/admin/templates), which are the underlying infrastructure for Coder [workspaces](https://coder.com/docs/user-guides/workspace-management).
12+
13+
-> Requires Coder [v2.18.0](https://github.com/coder/coder/releases/tag/v2.18.0) or later.
14+
15+
!> [`coder_git_auth`](https://registry.terraform.io/providers/coder/coder/1.0.4/docs/data-sources/git_auth) and owner related fields of [`coder_workspace`](https://registry.terraform.io/providers/coder/coder/1.0.4/docs/data-sources/workspace) data source have been removed. Follow the [Version 2 Upgrade Guide](https://registry.terraform.io/providers/codercom/coder/latest/docs/guides/version-2-upgrade) to update your code.
1216

1317
## Example
1418

‎go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/coder/terraform-provider-coder
22

33
go 1.22
44

5-
toolchain go1.22.3
5+
toolchain go1.22.9
66

77
require (
88
github.com/docker/docker v26.1.5+incompatible
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
page_title: "Terraform Coder Provider Version 2 Upgrade Guide"
3+
---
4+
5+
# Terraform Coder Provider Version 2 Upgrade Guide
6+
7+
Version 2.0.0 of the Coder provider for Terraform is a major release that introduces some changes that you will need to consider when upgrading.
8+
This guide is intended to help with the process, and focuses only on the changes from version 1.X to version 2.0.0.
9+
10+
!> Using Version 2.0.0 of the Coder provider requires Coder Server version [`2.18.0`](https://github.com/coder/coder/releases/tag/v2.18.0) or later.
11+
12+
Upgrade topics:
13+
14+
- [Provider Version Configuration](#provider-version-configuration)
15+
- [Provider Arguments](#provider-arguments)
16+
- [Data Source: coder_git_auth --> coder_external_auth](#data-source-coder_git_auth)
17+
- [Data Source: coder_workspace](#data-source-coder_workspace)
18+
19+
## Provider Version Configuration
20+
21+
-> Before upgrading to version 2.0.0, please first upgrade to the most recent 1.X version and ensure that your environment successfully runs [`terraform plan`](https://developer.hashicorp.com/terraform/cli/commands/plan) without unexpected changes or deprecation notices.
22+
23+
We highly recommend using [version constraints](https://developer.hashicorp.com/terraform/language/providers/requirements#version-constraints) when configuring Terraform providers.
24+
25+
26+
For example, given the previous configuration:
27+
28+
```terraform
29+
terraform {
30+
required_providers {
31+
coder = {
32+
source = "coder/coder"
33+
version = "~> 1.0.0"
34+
}
35+
}
36+
}
37+
38+
provider "coder" {
39+
feature_use_managed_variables = true
40+
}
41+
```
42+
43+
Update to the latest 2.X version:
44+
45+
```terraform
46+
terraform {
47+
required_providers {
48+
coder = {
49+
source = "coder/coder"
50+
version = "~> 2.0.0"
51+
}
52+
}
53+
}
54+
55+
provider "coder" {}
56+
```
57+
58+
## Provider Arguments
59+
60+
Version 2.0.0 removes the [`feature_use_managed_variables`](https://registry.terraform.io/providers/coder/coder/1.0.4/docs#feature_use_managed_variables-1) argument from the `provider` block.
61+
62+
63+
## Data Source: [`coder_git_auth`](https://registry.terraform.io/providers/coder/coder/1.0.4/docs/data-sources/git_auth)
64+
65+
If you are using this data source, you must replace it with the [`coder_external_auth`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/external_auth) data source. The `coder_external_auth` data source is a more generic data source that can be used to create any external authentication provider which supports OAuth2.
66+
67+
For example, given the previous configuration:
68+
69+
```terraform
70+
data "coder_git_auth" "example" {
71+
id = "example"
72+
}
73+
```
74+
75+
Update to the new data source:
76+
77+
```terraform
78+
data "coder_external_auth" "example" {
79+
id = "example"
80+
}
81+
```
82+
83+
## Data Source: [`coder_workspace`](https://registry.terraform.io/providers/coder/coder/1.0.4/docs/data-sources/workspace)
84+
85+
If you are using the `owner` properties of the `coder_workspace` data source, you must remove them and use the [`coder_workspace_owner`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner) data source instead. The `coder_workspace_owner` data source provides additional properties of the workspace owner.
86+
87+
Update your Terraform configuration to use the `coder_workspace_owner` data source instead and update the following attributes:
88+
89+
```terraform
90+
data "coder_workspace_owner" "me" {}
91+
```
92+
93+
- Remove `owner_id` attribute. Use [`data.coder_workspace_owner.me.id`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#id) instead.
94+
- Remove `owner` attribute. Use [`data.coder_workspace_owner.me.name`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#name) instead.
95+
- Remove `owner_name` attribute. Use [`data.coder_workspace_owner.me.full_name`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#full_name) instead.
96+
- Remove `owner_email` attribute. Use [`data.coder_workspace_owner.me.email`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#email) instead.
97+
- Remove `owner_groups` attribute. Use [`data.coder_workspace_owner.me.groups`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#groups) instead.
98+
- Remove `owner_oidc_access_token` attribute. Use [`data.coder_workspace_owner.me.oidc_access_token`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#oidc_access_token) instead.
99+
- Remove `owner_session_token` attribute. Use [`data.coder_workspace_owner.me.session_token`](https://registry.terraform.io/providers/coder/coder/2.0.0/docs/data-sources/workspace_owner#session_token) instead.
100+
101+
->While we do not anticipate these changes to affect existing resources, we strongly advice reviewing the plan produced by Terraform to ensure no resources are accidentally removed or altered in an undesired way. If you encounter any unexpected behavior, please report it by opening a GitHub [issue](https://github.com/coder/terraform-provider-coder/issues).

‎templates/index.md.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ description: |-
88

99
# Coder Provider
1010

11-
Terraform provider for managing Coder [templates](https://coder.com/docs/templates), which are the underlying infrastructure for Coder [workspaces](https://coder.com/docs/workspaces).
11+
Terraform provider for managing Coder [templates](https://coder.com/docs/admin/templates), which are the underlying infrastructure for Coder [workspaces](https://coder.com/docs/user-guides/workspace-management).
12+
13+
-> Requires Coder [v2.18.0](https://github.com/coder/coder/releases/tag/v2.18.0) or later.
14+
15+
!> [`coder_git_auth`](https://registry.terraform.io/providers/coder/coder/1.0.4/docs/data-sources/git_auth) and owner related fields of [`coder_workspace`](https://registry.terraform.io/providers/coder/coder/1.0.4/docs/data-sources/workspace) data source have been removed. Follow the [Version 2 Upgrade Guide](https://registry.terraform.io/providers/codercom/coder/latest/docs/guides/version-2-upgrade) to update your code.
1216

1317
## Example
1418

0 commit comments

Comments
 (0)
Please sign in to comment.