diff --git a/.images/filtered_flyio.png b/.images/filtered_flyio.png new file mode 100644 index 0000000..f7b0711 Binary files /dev/null and b/.images/filtered_flyio.png differ diff --git a/fly-region/README.md b/fly-region/README.md index 96babc3..5e71540 100644 --- a/fly-region/README.md +++ b/fly-region/README.md @@ -9,8 +9,49 @@ tags: [helper, parameter, fly] # Fly.io Region -A parameter with all fly.io regions. This allows developers to select the region closest to them. +This module adds Fly.io regions to your Coder template. Regions can be whitelisted using the `regions` argument and given custom names and custom icons with their respective map arguments (`custom_names`, `custom_icons`). ## Examples -TODO \ No newline at end of file +### Using default settings + +```hcl +module "fly-region" { + source = "https://registry.coder.com/modules/fly-region" +} +``` + +[]() + + +### Using region whitelist + +The regions argument can be used to display only the desired regions in the Coder parameter. + +```hcl +module "fly-region" { + source = "https://registry.coder.com/modules/fly-region" + default = "ams" + regions = ["ams", "arn", "atl"] +} +``` + + TODO: Add screenshot filtered_flyio.png + + +### Using custom icons and names + +Set custom icons and names with their respective maps. + +```hcl +module "fly-region" { + source = "https://registry.coder.com/modules/fly-region" + default = "ams" + custom_icons = { + "ams" = "/emojis/1f90e.png" + } + custom_names = { + "ams" = "We love the Netherlands!" + } +} +``` \ No newline at end of file diff --git a/fly-region/main.tf b/fly-region/main.tf index ceca802..cafb91e 100644 --- a/fly-region/main.tf +++ b/fly-region/main.tf @@ -270,7 +270,7 @@ data "coder_parameter" "fly_region" { name = "flyio_region" display_name = var.display_name description = var.description - default = var.default + default = (var.default != null && var.default != "") && (contains(var.regions, var.default) || length(var.regions) == 0) ? var.default : null mutable = var.mutable dynamic "option" { for_each = { for k, v in local.regions : k => v if anytrue([for d in var.regions : k == d ]) || length(var.regions) == 0 }