Skip to content

feat: Add examples/templates/do-linux for Digital Ocean Droplets #1749

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 13 commits into from
May 27, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: Add regions, images, sizes and variable for home volume size
  • Loading branch information
mafredri committed May 27, 2022
commit b599799f0e1edaf26d43fd1d0465faa282b22fc8
24 changes: 17 additions & 7 deletions examples/do-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,34 @@ variable "droplet_image" {
description = "Which Droplet image would you like to use for your workspace?"
default = "ubuntu-22-04-x64"
validation {
condition = contains(["debian-11-x64", "fedora-36-x64", "ubuntu-22-04-x64"], var.droplet_image)
error_message = "Value must be debian-11-x64, fedora-36-x64 or ubuntu-22-04-x64."
condition = contains(["ubuntu-22-04-x64", "ubuntu-20-04-x64", "fedora-36-x64", "fedora-35-x64", "debian-11-x64", "debian-10-x64", "centos-stream-9-x64", "centos-stream-8-x64", "rockylinux-8-x64", "rockylinux-8-4-x64"], var.droplet_image)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to conditionally include Fedora images based on if SSH key is set, but it's not possible, unfortunately :/ hashicorp/terraform#25609

error_message = "Value must be ubuntu-22-04-x64, ubuntu-20-04-x64, fedora-36-x64, fedora-35-x64, debian-11-x64, debian-10-x64, centos-stream-9-x64, centos-stream-8-x64, rockylinux-8-x64 or rockylinux-8-4-x64."
}
}

variable "droplet_size" {
description = "Which Droplet configuration would you like to use?"
validation {
condition = contains(["s-1vcpu-1gb", "s-1vcpu-2gb", "s-2vcpu-2gb"], var.droplet_size)
error_message = "Value must be s-1vcpu-1gb, s-1vcpu-2gb or s-2vcpu-2gb."
condition = contains(["s-1vcpu-1gb", "s-1vcpu-2gb", "s-2vcpu-2gb", "s-2vcpu-4gb", "s-4vcpu-8gb", "s-8vcpu-16gb"], var.droplet_size)
error_message = "Value must be s-1vcpu-1gb, s-1vcpu-2gb, s-2vcpu-2gb, s-2vcpu-4gb, s-4vcpu-8gb or s-8vcpu-16gb."
}
}

variable "home_volume_size" {
type = number
description = "How large would you like your home volume to be (in GB)?"
default = 20
validation {
condition = var.home_volume_size >= 1
error_message = "Value must be greather than or equal to 1."
}
}

variable "region" {
description = "Which region would you like to use?"
validation {
condition = contains(["nyc1", "nyc3", "ams3"], var.region)
error_message = "Value must be nyc1, nyc3, or ams3."
condition = contains(["nyc1", "nyc2", "nyc3", "sfo1", "sfo2", "sfo3", "ams2", "ams3", "sgp1", "lon1", "fra1", "tor1", "blr1"], var.region)
error_message = "Value must be nyc1, nyc2, nyc3, sfo1, sfo2, sfo3, ams2, ams3, sgp1, lon1, fra1, tor1 or blr1."
}
}

Expand All @@ -73,7 +83,7 @@ resource "coder_agent" "dev" {
resource "digitalocean_volume" "home_volume" {
region = var.region
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-home"
size = 20
size = var.home_volume_size
initial_filesystem_type = "ext4"
initial_filesystem_label = "coder-home"
}
Expand Down