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
pull/44/head
Muhammad Atif Ali 2 years ago committed by GitHub
parent b18ac37cbb
commit 2e829b19a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

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
the region closest to them.
![AWS Regions](../.images/aws-region.png)
## Examples
### Default Region

@ -10,15 +10,18 @@ tags: [gcp, regions, zones, helper]
This module adds Google Cloud Platform regions to your Coder template.
![GCP Regions](../.images/gcp-regions.png)
## Examples
1. Add only GPU zones in the US West 1 region:
```hcl
module "regions" {
source = "https://registry.coder.com/modules/gcp-regions"
default = ["us-west1"]
gpu_only = true
module "gcp_regions" {
source = "git::https://github.com/coder/modules.git//gcp-region?branch=gcp-region"
default = ["us-west1-a"]
regions = ["us-west1"]
gpu_only = false
}
```
@ -26,7 +29,19 @@ This module adds Google Cloud Platform regions to your Coder template.
```hcl
module "regions" {
source = "https://registry.coder.com/modules/gcp-regions"
default = ["europe-west"]
source = "https://registry.coder.com/modules/gcp-regions"
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" {
default = null
description = "Default zone"
type = string
}
variable "regions" {
description = "List of GCP regions to include."
type = list(string)
default = ["us-central1"]
@ -51,6 +57,12 @@ variable "custom_icons" {
type = map(string)
}
variable "single_zone_per_region" {
default = true
description = "Whether to only include a single zone per region."
type = bool
}
locals {
zones = {
# US Central
@ -343,17 +355,17 @@ locals {
"europe-west2-a" = {
gpu = true
name = "London, England (a)"
icon = "/emojis/1f173-1f1ff.png"
icon = "/emojis/1f1ec-1f1e7.png"
}
"europe-west2-b" = {
gpu = true
name = "London, England (b)"
icon = "/emojis/1f173-1f1ff.png"
icon = "/emojis/1f1ec-1f1e7.png"
}
"europe-west2-c" = {
gpu = false
name = "London, England (c)"
icon = "/emojis/1f173-1f1ff.png"
icon = "/emojis/1f1ec-1f1e7.png"
}
"europe-west3-b" = {
@ -702,14 +714,16 @@ data "coder_parameter" "region" {
description = var.description
icon = "/icon/gcp.png"
mutable = var.mutable
default = var.default != null && var.default != "" ? var.default : null
dynamic "option" {
for_each = {
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 {
icon = try(var.custom_icons[option.key], option.value.icon)
name = try(var.custom_names[option.key], option.value.name)
icon = try(var.custom_icons[option.key], option.value.icon)
# 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
value = option.key
}
@ -717,5 +731,11 @@ data "coder_parameter" "region" {
}
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)
}

Loading…
Cancel
Save