Skip to content

Commit a22ccaa

Browse files
authored
Merge branch 'main' into matifali/migration-guide
2 parents c0fb526 + 493a0f1 commit a22ccaa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+667
-837
lines changed

.github/workflows/cla.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
- name: "CLA Assistant"
1313
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
14-
uses: contributor-assistant/github-action@v2.4.0
14+
uses: contributor-assistant/github-action@v2.6.1
1515
env:
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1717
# the below token should have repo scope and must be manually added by you in the repository's secret

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ jobs:
3131

3232
- name: Import GPG key
3333
id: import_gpg
34-
uses: crazy-max/ghaction-import-gpg@v6.1.0
34+
uses: crazy-max/ghaction-import-gpg@v6.2.0
3535
with:
3636
# These secrets will need to be configured for the repository:
3737
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
3838
passphrase: ${{ secrets.PASSPHRASE }}
3939

4040
- name: Run GoReleaser
41-
uses: goreleaser/goreleaser-action@v5.1.0
41+
uses: goreleaser/goreleaser-action@v6.1.0
4242
with:
4343
version: latest
44-
args: release --rm-dist
44+
args: release --clean
4545
env:
4646
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
4747
# GitHub sets this automatically

.github/workflows/test.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,11 @@ jobs:
6464
fail-fast: false
6565
matrix:
6666
terraform:
67-
- "1.0.*"
68-
- "1.1.*"
69-
- "1.2.*"
70-
- "1.3.*"
71-
- "1.4.*"
7267
- "1.5.*"
7368
- "1.6.*"
7469
- "1.7.*"
7570
- "1.8.*"
71+
- "1.9.*"
7672
steps:
7773
- name: Set up Go
7874
uses: actions/setup-go@v5
@@ -112,7 +108,7 @@ jobs:
112108

113109
- uses: hashicorp/setup-terraform@v3
114110
with:
115-
terraform_version: "1.3.*"
111+
terraform_version: "latest"
116112
terraform_wrapper: false
117113

118114
- name: Check out code into the Go module directory

.goreleaser.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ release:
5757
# If you want to manually examine the release before its live, uncomment this line:
5858
# draft: true
5959
changelog:
60-
skip: true
60+
disable: true

docs/data-sources/git_auth.md

-52
This file was deleted.

docs/data-sources/workspace.md

+43-10
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,51 @@ Use this data source to get information for the active workspace build.
1313
## Example Usage
1414

1515
```terraform
16-
data "coder_workspace" "dev" {
16+
provider "coder" {}
17+
18+
provider "docker" {}
19+
20+
data "coder_workspace" "me" {}
21+
22+
data "coder_workspace_owner" "me" {}
23+
24+
resource "coder_agent" "dev" {
25+
arch = "amd64"
26+
os = "linux"
27+
dir = "/workspace"
1728
}
1829
19-
resource "kubernetes_pod" "dev" {
20-
count = data.coder_workspace.dev.transition == "start" ? 1 : 0
30+
resource "docker_container" "workspace" {
31+
count = data.coder_workspace.me.start_count
32+
image = docker_image.main.name
33+
# Uses lower() to avoid Docker restriction on container names.
34+
name = "coder-${data.coder_workspace_owner.me.name}-${lower(data.coder_workspace.me.name)}"
35+
# Hostname makes the shell more user friendly: coder@my-workspace:~$
36+
hostname = data.coder_workspace.me.name
37+
# Use the docker gateway if the access URL is 127.0.0.1
38+
entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")]
39+
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
40+
host {
41+
host = "host.docker.internal"
42+
ip = "host-gateway"
43+
}
44+
# Add labels in Docker to keep track of orphan resources.
45+
labels {
46+
label = "coder.owner"
47+
value = data.coder_workspace_owner.me.name
48+
}
49+
labels {
50+
label = "coder.owner_id"
51+
value = data.coder_workspace_owner.me.id
52+
}
53+
labels {
54+
label = "coder.workspace_id"
55+
value = data.coder_workspace.me.id
56+
}
57+
labels {
58+
label = "coder.workspace_name"
59+
value = data.coder_workspace.me.name
60+
}
2161
}
2262
```
2363

@@ -30,13 +70,6 @@ resource "kubernetes_pod" "dev" {
3070
- `access_url` (String) The access URL of the Coder deployment provisioning this workspace.
3171
- `id` (String) UUID of the workspace.
3272
- `name` (String) Name of the workspace.
33-
- `owner` (String, **Deprecated**: Use `coder_workspace_owner.name` instead.) Username of the workspace owner.
34-
- `owner_email` (String, **Deprecated**: Use `coder_workspace_owner.email` instead.) Email address of the workspace owner.
35-
- `owner_groups` (List of String, **Deprecated**: Use `coder_workspace_owner.groups` instead.) List of groups the workspace owner belongs to.
36-
- `owner_id` (String, **Deprecated**: Use `coder_workspace_owner.id` instead.) UUID of the workspace owner.
37-
- `owner_name` (String, **Deprecated**: Use `coder_workspace_owner.full_name` instead.) Name of the workspace owner.
38-
- `owner_oidc_access_token` (String, **Deprecated**: Use `coder_workspace_owner.oidc_access_token` instead.) A valid OpenID Connect access token of the workspace owner. This is only available if the workspace owner authenticated with OpenID Connect. If a valid token cannot be obtained, this value will be an empty string.
39-
- `owner_session_token` (String, **Deprecated**: Use `coder_workspace_owner.session_token` instead.) Session token for authenticating with a Coder deployment. It is regenerated everytime a workspace is started.
4073
- `start_count` (Number) A computed count based on `transition` state. If `start`, count will equal 1.
4174
- `template_id` (String) ID of the workspace's template.
4275
- `template_name` (String) Name of the workspace's template.

docs/data-sources/workspace_owner.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ Use this data source to fetch information about the workspace owner.
1515
```terraform
1616
provider "coder" {}
1717
18-
data "coder_workspace" "me" {}
19-
2018
data "coder_workspace_owner" "me" {}
2119
2220
resource "coder_agent" "dev" {
2321
arch = "amd64"
2422
os = "linux"
25-
dir = local.repo_dir
23+
dir = "/workspace"
2624
env = {
2725
OIDC_TOKEN : data.coder_workspace_owner.me.oidc_access_token,
2826
}
@@ -36,7 +34,7 @@ resource "coder_env" "git_author_name" {
3634
}
3735
3836
resource "coder_env" "git_author_email" {
39-
agent_id = var.agent_id
37+
agent_id = coder_agent.dev.id
4038
name = "GIT_AUTHOR_EMAIL"
4139
value = data.coder_workspace_owner.me.email
4240
count = data.coder_workspace_owner.me.email != "" ? 1 : 0
@@ -52,6 +50,7 @@ resource "coder_env" "git_author_email" {
5250
- `full_name` (String) The full name of the user.
5351
- `groups` (List of String) The groups of which the user is a member.
5452
- `id` (String) The UUID of the workspace owner.
53+
- `login_type` (String) The type of login the user has.
5554
- `name` (String) The username of the user.
5655
- `oidc_access_token` (String) A valid OpenID Connect access token of the workspace owner. This is only available if the workspace owner authenticated with OpenID Connect. If a valid token cannot be obtained, this value will be an empty string.
5756
- `session_token` (String) Session token for authenticating with a Coder deployment. It is regenerated every time a workspace is started.

docs/index.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
page_title: "Coder Provider"
44
subcategory: "Infrastructure"
55
description: |-
6-
Terraform provider for Coder. Coder is a self-hosted cloud development environment that allows enterprises to create consistent, secure, and scalable development environments for their teams.
7-
6+
Terraform provider for managing Coder templates, which are the underlying infrastructure for Coder workspaces.
87
---
98

109
# Coder Provider
1110

12-
The Coder provider is used to help create [Coder](https://coder.com) templates. Coder is a self-hosted cloud development environment that allows enterprises to create consistent, secure, and scalable development environments for their teams.
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).
1312

1413
-> Requires Coder v2.13.0 or later.
1514

@@ -69,5 +68,4 @@ resource "google_compute_instance" "dev" {
6968

7069
### Optional
7170

72-
- `feature_use_managed_variables` (Boolean, **Deprecated**: Terraform variables are now exclusively utilized for template-wide variables after the removal of support for legacy parameters.) Feature: use managed Terraform variables. The feature flag is not used anymore as Terraform variables are now exclusively utilized for template-wide variables.
7371
- `url` (String) The URL to access Coder.

docs/resources/agent.md

-3
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,12 @@ resource "kubernetes_pod" "dev" {
7676
- `dir` (String) The starting directory when a user creates a shell session. Defaults to `"$HOME"`.
7777
- `display_apps` (Block Set, Max: 1) The list of built-in apps to display in the agent bar. (see [below for nested schema](#nestedblock--display_apps))
7878
- `env` (Map of String) A mapping of environment variables to set inside the workspace.
79-
- `login_before_ready` (Boolean, **Deprecated**: Configure `startup_script_behavior` instead. This attribute will be removed in a future version of the provider.) This option defines whether or not the user can (by default) login to the workspace before it is ready. Ready means that e.g. the `startup_script` is done and has exited. When enabled, users may see an incomplete workspace when logging in.
8079
- `metadata` (Block List) Each `metadata` block defines a single item consisting of a key/value pair. This feature is in alpha and may break in future releases. (see [below for nested schema](#nestedblock--metadata))
8180
- `motd_file` (String) The path to a file within the workspace containing a message to display to users when they login via SSH. A typical value would be `"/etc/motd"`.
8281
- `order` (Number) The order determines the position of agents in the UI presentation. The lowest order is shown first and agents with equal order are sorted by name (ascending order).
8382
- `shutdown_script` (String) A script to run before the agent is stopped. The script should exit when it is done to signal that the workspace can be stopped. This option is an alias for defining a `coder_script` resource with `run_on_stop` set to `true`.
84-
- `shutdown_script_timeout` (Number, **Deprecated**: This feature is deprecated and has no effect. This attribute will be removed in a future version of the provider.) Time in seconds until the agent lifecycle status is marked as timed out during shutdown, this happens when the shutdown script has not completed (exited) in the given time.
8583
- `startup_script` (String) A script to run after the agent starts. The script should exit when it is done to signal that the agent is ready. This option is an alias for defining a `coder_script` resource with `run_on_start` set to `true`.
8684
- `startup_script_behavior` (String) This option sets the behavior of the `startup_script`. When set to `"blocking"`, the `startup_script` must exit before the workspace is ready. When set to `"non-blocking"`, the `startup_script` may run in the background and the workspace will be ready immediately. Default is `"non-blocking"`, although `"blocking"` is recommended. This option is an alias for defining a `coder_script` resource with `start_blocks_login` set to `true` (blocking).
87-
- `startup_script_timeout` (Number, **Deprecated**: This feature is deprecated and has no effect. This attribute will be removed in a future version of the provider.) Time in seconds until the agent lifecycle status is marked as timed out during start, this happens when the startup script has not completed (exited) in the given time.
8885
- `troubleshooting_url` (String) A URL to a document with instructions for troubleshooting problems with the agent.
8986

9087
### Read-Only

docs/resources/app.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ resource "coder_app" "vim" {
6363
- `display_name` (String) A display name to identify the app. Defaults to the slug.
6464
- `external` (Boolean) Specifies whether `url` is opened on the client machine instead of proxied through the workspace.
6565
- `healthcheck` (Block Set, Max: 1) HTTP health checking to determine the application readiness. (see [below for nested schema](#nestedblock--healthcheck))
66+
- `hidden` (Boolean) Determines if the app is visible in the UI (minimum Coder version: v2.16).
6667
- `icon` (String) A URL to an icon that will display in the dashboard. View built-in icons here: https://github.com/coder/coder/tree/main/site/static/icon. Use a built-in icon with `"${data.coder_workspace.me.access_url}/icon/<path>"`.
67-
- `name` (String, **Deprecated**: `name` on apps is deprecated, use `display_name` instead) A display name to identify the app.
6868
- `order` (Number) The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order).
69-
- `relative_path` (Boolean, **Deprecated**: `relative_path` on apps is deprecated, use `subdomain` instead.) Specifies whether the URL will be accessed via a relative path or wildcard. Use if wildcard routing is unavailable. Defaults to `true`.
7069
- `share` (String) Determines the level which the application is shared at. Valid levels are `"owner"` (default), `"authenticated"` and `"public"`. Level `"owner"` disables sharing on the app, so only the workspace owner can access it. Level `"authenticated"` shares the app with all authenticated users. Level `"public"` shares it with any user, including unauthenticated users. Permitted application sharing levels can be configured site-wide via a flag on `coder server` (Enterprise only).
7170
- `subdomain` (Boolean) Determines whether the app will be accessed via it's own subdomain or whether it will be accessed via a path on Coder. If wildcards have not been setup by the administrator then apps with `subdomain` set to `true` will not be accessible. Defaults to `false`.
7271
- `url` (String) An external url if `external=true` or a URL to be proxied to from inside the workspace. This should be of the form `http://localhost:PORT[/SUBPATH]`. Either `command` or `url` may be specified, but not both.

docs/resources/metadata.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
page_title: "coder_metadata Resource - terraform-provider-coder"
44
subcategory: ""
55
description: |-
6-
Use this resource to attach metadata to a resource. They will be displayed in the Coder dashboard.
6+
Use this resource to attach metadata to a resource. They will be displayed in the Coder dashboard alongside the resource. The resource containing the agent, and it's metadata, will be shown by default.
7+
Alternatively, to attach metadata to the agent, use a metadata block within a coder_agent resource.
78
---
89

910
# coder_metadata (Resource)
1011

11-
Use this resource to attach metadata to a resource. They will be displayed in the Coder dashboard.
12+
Use this resource to attach metadata to a resource. They will be displayed in the Coder dashboard alongside the resource. The resource containing the agent, and it's metadata, will be shown by default.
13+
14+
Alternatively, to attach metadata to the agent, use a `metadata` block within a `coder_agent` resource.
1215

1316
## Example Usage
1417

@@ -82,7 +85,7 @@ Required:
8285
Optional:
8386

8487
- `sensitive` (Boolean) Set to `true` to for items such as API keys whose values should be hidden from view by default. Note that this does not prevent metadata from being retrieved using the API, so it is not suitable for secrets that should not be exposed to workspace users.
85-
- `value` (String) The value of this metadata item.
88+
- `value` (String) The value of this metadata item. Supports basic Markdown, including hyperlinks.
8689

8790
Read-Only:
8891

examples/data-sources/coder_git_auth/data-source.tf

-20
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,46 @@
1-
data "coder_workspace" "dev" {
1+
provider "coder" {}
2+
3+
provider "docker" {}
4+
5+
data "coder_workspace" "me" {}
6+
7+
data "coder_workspace_owner" "me" {}
8+
9+
resource "coder_agent" "dev" {
10+
arch = "amd64"
11+
os = "linux"
12+
dir = "/workspace"
213
}
314

4-
resource "kubernetes_pod" "dev" {
5-
count = data.coder_workspace.dev.transition == "start" ? 1 : 0
15+
resource "docker_container" "workspace" {
16+
count = data.coder_workspace.me.start_count
17+
image = docker_image.main.name
18+
# Uses lower() to avoid Docker restriction on container names.
19+
name = "coder-${data.coder_workspace_owner.me.name}-${lower(data.coder_workspace.me.name)}"
20+
# Hostname makes the shell more user friendly: coder@my-workspace:~$
21+
hostname = data.coder_workspace.me.name
22+
# Use the docker gateway if the access URL is 127.0.0.1
23+
entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")]
24+
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
25+
host {
26+
host = "host.docker.internal"
27+
ip = "host-gateway"
28+
}
29+
# Add labels in Docker to keep track of orphan resources.
30+
labels {
31+
label = "coder.owner"
32+
value = data.coder_workspace_owner.me.name
33+
}
34+
labels {
35+
label = "coder.owner_id"
36+
value = data.coder_workspace_owner.me.id
37+
}
38+
labels {
39+
label = "coder.workspace_id"
40+
value = data.coder_workspace.me.id
41+
}
42+
labels {
43+
label = "coder.workspace_name"
44+
value = data.coder_workspace.me.name
45+
}
646
}

examples/data-sources/coder_workspace_owner/data-source.tf

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
provider "coder" {}
22

3-
data "coder_workspace" "me" {}
4-
53
data "coder_workspace_owner" "me" {}
64

75
resource "coder_agent" "dev" {
86
arch = "amd64"
97
os = "linux"
10-
dir = local.repo_dir
8+
dir = "/workspace"
119
env = {
1210
OIDC_TOKEN : data.coder_workspace_owner.me.oidc_access_token,
1311
}
@@ -21,7 +19,7 @@ resource "coder_env" "git_author_name" {
2119
}
2220

2321
resource "coder_env" "git_author_email" {
24-
agent_id = var.agent_id
22+
agent_id = coder_agent.dev.id
2523
name = "GIT_AUTHOR_EMAIL"
2624
value = data.coder_workspace_owner.me.email
2725
count = data.coder_workspace_owner.me.email != "" ? 1 : 0

0 commit comments

Comments
 (0)