|
|
@ -22,6 +22,12 @@ variable "description" {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
variable "default" {
|
|
|
|
variable "default" {
|
|
|
|
|
|
|
|
default = null
|
|
|
|
|
|
|
|
description = "Default zone"
|
|
|
|
|
|
|
|
type = string
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
variable "regions" {
|
|
|
|
description = "List of GCP regions to include."
|
|
|
|
description = "List of GCP regions to include."
|
|
|
|
type = list(string)
|
|
|
|
type = list(string)
|
|
|
|
default = ["us-central1"]
|
|
|
|
default = ["us-central1"]
|
|
|
@ -51,6 +57,12 @@ variable "custom_icons" {
|
|
|
|
type = map(string)
|
|
|
|
type = map(string)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
variable "single_zone_per_region" {
|
|
|
|
|
|
|
|
default = true
|
|
|
|
|
|
|
|
description = "Whether to only include a single zone per region."
|
|
|
|
|
|
|
|
type = bool
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
locals {
|
|
|
|
locals {
|
|
|
|
zones = {
|
|
|
|
zones = {
|
|
|
|
# US Central
|
|
|
|
# US Central
|
|
|
@ -343,17 +355,17 @@ locals {
|
|
|
|
"europe-west2-a" = {
|
|
|
|
"europe-west2-a" = {
|
|
|
|
gpu = true
|
|
|
|
gpu = true
|
|
|
|
name = "London, England (a)"
|
|
|
|
name = "London, England (a)"
|
|
|
|
icon = "/emojis/1f173-1f1ff.png"
|
|
|
|
icon = "/emojis/1f1ec-1f1e7.png"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"europe-west2-b" = {
|
|
|
|
"europe-west2-b" = {
|
|
|
|
gpu = true
|
|
|
|
gpu = true
|
|
|
|
name = "London, England (b)"
|
|
|
|
name = "London, England (b)"
|
|
|
|
icon = "/emojis/1f173-1f1ff.png"
|
|
|
|
icon = "/emojis/1f1ec-1f1e7.png"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"europe-west2-c" = {
|
|
|
|
"europe-west2-c" = {
|
|
|
|
gpu = false
|
|
|
|
gpu = false
|
|
|
|
name = "London, England (c)"
|
|
|
|
name = "London, England (c)"
|
|
|
|
icon = "/emojis/1f173-1f1ff.png"
|
|
|
|
icon = "/emojis/1f1ec-1f1e7.png"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
"europe-west3-b" = {
|
|
|
|
"europe-west3-b" = {
|
|
|
@ -702,14 +714,16 @@ data "coder_parameter" "region" {
|
|
|
|
description = var.description
|
|
|
|
description = var.description
|
|
|
|
icon = "/icon/gcp.png"
|
|
|
|
icon = "/icon/gcp.png"
|
|
|
|
mutable = var.mutable
|
|
|
|
mutable = var.mutable
|
|
|
|
|
|
|
|
default = var.default != null && var.default != "" ? var.default : null
|
|
|
|
dynamic "option" {
|
|
|
|
dynamic "option" {
|
|
|
|
for_each = {
|
|
|
|
for_each = {
|
|
|
|
for k, v in local.zones : k => v
|
|
|
|
for k, v in local.zones : k => v
|
|
|
|
if anytrue([for d in var.default : startswith(k, d)]) && (!var.gpu_only || v.gpu)
|
|
|
|
if anytrue([for d in var.regions : startswith(k, d)]) && (!var.gpu_only || v.gpu) && (!var.single_zone_per_region || endswith(k, "-a"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
content {
|
|
|
|
content {
|
|
|
|
icon = try(var.custom_icons[option.key], option.value.icon)
|
|
|
|
icon = try(var.custom_icons[option.key], option.value.icon)
|
|
|
|
name = try(var.custom_names[option.key], option.value.name)
|
|
|
|
# if single_zone_per_region is true, remove the zone letter from the name
|
|
|
|
|
|
|
|
name = try(var.custom_names[option.key], var.single_zone_per_region ? substr(option.value.name, 0, length(option.value.name) - 4) : option.value.name)
|
|
|
|
description = option.key
|
|
|
|
description = option.key
|
|
|
|
value = option.key
|
|
|
|
value = option.key
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -717,5 +731,11 @@ data "coder_parameter" "region" {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
output "value" {
|
|
|
|
output "value" {
|
|
|
|
value = data.coder_parameter.region.value
|
|
|
|
description = "GCP zone identifier."
|
|
|
|
|
|
|
|
value = data.coder_parameter.region.value
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output "region" {
|
|
|
|
|
|
|
|
description = "GCP region identifier."
|
|
|
|
|
|
|
|
value = substr(data.coder_parameter.region.value, 0, length(data.coder_parameter.region.value) - 2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|