-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmain.tf
94 lines (92 loc) · 2.38 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
locals {
regions = concat(var.additional_regions, [
"africa-south1",
"asia-east1",
"asia-east2",
"asia-northeast1",
"asia-northeast2",
"asia-northeast3",
"asia-south1",
"asia-south2",
"asia-southeast1",
"asia-southeast2",
"australia-southeast1",
"australia-southeast2",
"europe-central2",
"europe-north1",
"europe-southwest1",
"europe-west1",
"europe-west2",
"europe-west3",
"europe-west4",
"europe-west6",
"europe-west8",
"europe-west9",
"europe-west10",
"europe-west12",
"me-central1",
"me-central2",
"me-west1",
"northamerica-northeast1",
"northamerica-northeast2",
"southamerica-east1",
"southamerica-west1",
"us-central1",
"us-east1",
"us-east4",
"us-east5",
"us-south1",
"us-west1",
"us-west2",
"us-west3",
"us-west4",
])
# Compute the regional shortname from component parts
continent_short_name = {
africa = "af"
asia = "az"
australia = "au"
europe = "eu"
northamerica = "na"
southamerica = "sa"
us = "us"
me = "me"
}
parts = var.region == null ? [] : split("-", var.region)
region_short_name = var.region == null ? "" : join("", [
local.continent_short_name[local.parts[0]],
replace(local.parts[1], "/(n)orth|(s)outh|(e)ast|(w)est|(c)entral/", "$1$2$3$4$5")
])
# Same computation but kick back a map
region_short_name_map = { for full_region in local.regions : full_region =>
join(
"", [
local.continent_short_name[split(
"-",
full_region
)[0]],
replace(
split(
"-", full_region)[1],
"/(n)orth|(s)outh|(e)ast|(w)est|(c)entral/",
"$1$2$3$4$5"
)
]
)
}
}