Skip to content

Commit 5b41d7a

Browse files
committed
chore: more sensible variable defaults
1 parent 63572d9 commit 5b41d7a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

examples/templates/digitalocean-linux/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ To deploy workspaces as DigitalOcean Droplets, you'll need:
2525
- Remove the following sections from the `main.tf` file if you don't want to
2626
associate your workspaces with a project:
2727

28-
- `variable "step2_do_project_id"`
28+
- `variable "do_project_id"`
2929
- `resource "digitalocean_project_resources" "project"`
3030

3131
- **Optional:** DigitalOcean SSH key ID (obtain via the `doctl` CLI by running
3232
`doctl compute ssh-key list`)
3333

34-
- Note that this is only required for Fedora images to work.
34+
- Note that this is only required for Fedora images to work.
3535

3636
### Authentication
3737

examples/templates/digitalocean-linux/main.tf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,26 @@ terraform {
99
}
1010
}
1111

12-
provider "coder" {
13-
}
12+
provider "coder" {}
1413

15-
variable "step1_do_project_id" {
14+
variable "do_project_id" {
1615
type = string
1716
description = <<-EOF
18-
Enter project ID
17+
DigitalOcean project ID
1918
2019
$ doctl projects list
2120
EOF
2221
sensitive = true
2322

2423
validation {
25-
# make sure length of alphanumeric string is 36
26-
condition = length(var.step1_do_project_id) == 36
24+
# make sure length of alphanumeric string is 36 (UUIDv4 size)
25+
condition = length(var.do_project_id) == 36
2726
error_message = "Invalid Digital Ocean Project ID."
2827
}
2928

3029
}
3130

32-
variable "step2_do_admin_ssh_key" {
31+
variable "do_admin_ssh_key" {
3332
type = number
3433
description = <<-EOF
3534
Enter admin SSH key ID (some Droplet images require an SSH key to be set):
@@ -40,10 +39,11 @@ variable "step2_do_admin_ssh_key" {
4039
4140
$ doctl compute ssh-key list
4241
EOF
43-
sensitive = true
42+
sensitive = true
43+
default = 0
4444

4545
validation {
46-
condition = var.step2_do_admin_ssh_key >= 0
46+
condition = var.do_admin_ssh_key >= 0
4747
error_message = "Invalid Digital Ocean SSH key ID, a number is required."
4848
}
4949
}
@@ -291,11 +291,11 @@ resource "digitalocean_droplet" "workspace" {
291291
coder_agent_token = coder_agent.main.token
292292
})
293293
# Required to provision Fedora.
294-
ssh_keys = var.step2_do_admin_ssh_key > 0 ? [var.step2_do_admin_ssh_key] : []
294+
ssh_keys = var.do_admin_ssh_key > 0 ? [var.do_admin_ssh_key] : []
295295
}
296296

297297
resource "digitalocean_project_resources" "project" {
298-
project = var.step1_do_project_id
298+
project = var.do_project_id
299299
# Workaround for terraform plan when using count.
300300
resources = length(digitalocean_droplet.workspace) > 0 ? [
301301
digitalocean_volume.home_volume.urn,

0 commit comments

Comments
 (0)