Skip to content

Commit 4e0acdc

Browse files
Emyrkmatifali
andauthored
chore: implement dogfood template to select region based on user group (#18115)
Co-authored-by: Atif Ali <atif@coder.com>
1 parent 232c72f commit 4e0acdc

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

dogfood/coder/main.tf

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,29 @@ data "coder_parameter" "image_type" {
130130
}
131131
}
132132

133+
locals {
134+
default_regions = {
135+
// keys should match group names
136+
"north-america" : "us-pittsburgh"
137+
"europe" : "eu-helsinki"
138+
"australia" : "ap-sydney"
139+
"south-america" : "sa-saopaulo"
140+
"africa" : "za-cpt"
141+
}
142+
143+
user_groups = data.coder_workspace_owner.me.groups
144+
user_region = coalescelist([
145+
for g in local.user_groups :
146+
local.default_regions[g] if contains(keys(local.default_regions), g)
147+
], ["us-pittsburgh"])[0]
148+
}
149+
150+
133151
data "coder_parameter" "region" {
134152
type = "string"
135153
name = "Region"
136154
icon = "/emojis/1f30e.png"
137-
default = "us-pittsburgh"
155+
default = local.user_region
138156
option {
139157
icon = "/emojis/1f1fa-1f1f8.png"
140158
name = "Pittsburgh"

0 commit comments

Comments
 (0)