chore: update gcp regions and add screenshots (#37)
* chore: add default zone * Update README.md * handle case when default is not provided * use single zone per name * update README.md * fix docs * fixup! * use truncation * fix England flag * fixup flag emoji * add screenshot * add AWS regions screenshot * output both zone and region identifiers
This commit is contained in:
committed by
GitHub
parent
b18ac37cbb
commit
2e829b19a4
BIN
.images/aws-regions.png
Normal file
BIN
.images/aws-regions.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 176 KiB |
BIN
.images/gcp-regions.png
Normal file
BIN
.images/gcp-regions.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 149 KiB |
@@ -12,6 +12,8 @@ tags: [helper, parameter]
|
|||||||
A parameter with all AWS regions. This allows developers to select
|
A parameter with all AWS regions. This allows developers to select
|
||||||
the region closest to them.
|
the region closest to them.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Default Region
|
### Default Region
|
||||||
|
|||||||
@@ -10,15 +10,18 @@ tags: [gcp, regions, zones, helper]
|
|||||||
|
|
||||||
This module adds Google Cloud Platform regions to your Coder template.
|
This module adds Google Cloud Platform regions to your Coder template.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
1. Add only GPU zones in the US West 1 region:
|
1. Add only GPU zones in the US West 1 region:
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
module "regions" {
|
module "gcp_regions" {
|
||||||
source = "https://registry.coder.com/modules/gcp-regions"
|
source = "git::https://github.com/coder/modules.git//gcp-region?branch=gcp-region"
|
||||||
default = ["us-west1"]
|
default = ["us-west1-a"]
|
||||||
gpu_only = true
|
regions = ["us-west1"]
|
||||||
|
gpu_only = false
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -27,6 +30,18 @@ This module adds Google Cloud Platform regions to your Coder template.
|
|||||||
```hcl
|
```hcl
|
||||||
module "regions" {
|
module "regions" {
|
||||||
source = "https://registry.coder.com/modules/gcp-regions"
|
source = "https://registry.coder.com/modules/gcp-regions"
|
||||||
default = ["europe-west"]
|
regions = ["europe-west"]
|
||||||
|
single_zone_per_region = false
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Add a single zone from each region in US and Europe that laos has GPUs
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "regions" {
|
||||||
|
source = "https://registry.coder.com/modules/gcp-regions"
|
||||||
|
regions = ["us", "europe"]
|
||||||
|
gpu_only = true
|
||||||
|
single_zone_per_region = true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -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" {
|
||||||
|
description = "GCP zone identifier."
|
||||||
value = data.coder_parameter.region.value
|
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)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user