-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocals.tf
50 lines (41 loc) · 1.38 KB
/
locals.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
locals {
service_account_key_file = "${path.module}/${var.service_account_key_file}"
service_account_static_key_file = "${path.module}/${var.service_account_static_key_file}"
config_file = "${path.module}/${var.config_file}"
}
data "external" "sa_json" {
program = [
"jq",
"-f",
"${local.service_account_static_key_file}"
]
}
data "external" "config_json" {
program = [
"jq",
"-f",
"${local.config_file}"
]
}
data "http" "ip" {
url = "https://ipv4.icanhazip.com"
}
locals {
ip = chomp(data.http.ip.response_body)
ip_cidr = "${chomp(data.http.ip.response_body)}/32"
_allowed_ip = data.external.config_json.result.allowed_ip
allowed_ip = [for ip in split(",", local._allowed_ip) : "${ip}/32"]
}
locals {
postgres_version = data.external.config_json.result.postgres_version
postgres_db_list = split(",", data.external.config_json.result.postgres_db_list)
}
locals {
provider_endpoint = data.external.sa_json.result.provider_endpoint
storage_endpoint = data.external.sa_json.result.storage_endpoint
sa_access_key = data.external.sa_json.result.static_access_key
sa_secret_key = data.external.sa_json.result.static_secret_key
cloud_id = data.external.config_json.result.cloud_id
folder_id = data.external.config_json.result.folder_id
network_id = data.external.config_json.result.network_id
}