forked from walrus-catalog/terraform-docker-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutputs.tf
88 lines (75 loc) · 2.52 KB
/
outputs.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
locals {
hosts = [
format("%s.%s.svc.%s", local.master_name, local.namespace, local.domain_suffix)
]
hosts_readonly = local.architecture == "replication" ? [
for i in range(0, var.replication_readonly_replicas) : format("%s-slave-%d.%s.svc.%s", local.resource_name, i, local.namespace, local.domain_suffix)
] : []
endpoints = flatten([
for c in local.hosts : formatlist("%s:5432", c)
])
endpoints_readonly = [
for c in(local.hosts_readonly != null ? local.hosts_readonly : []) : format("%s:5432", c)
]
}
#
# Orchestration
#
output "context" {
description = "The input context, a map, which is used for orchestration."
value = var.context
}
output "refer" {
description = "The refer, a map, including hosts, ports and account, which is used for dependencies or collaborations."
sensitive = true
value = {
schema = "docker:postgresql"
params = {
selector = local.labels
hosts = local.hosts
hosts_readonly = local.hosts_readonly
ports = [5432]
endpoints = local.endpoints
endpoints_readonly = local.endpoints_readonly
database = local.database
username = local.username
password = nonsensitive(local.password)
}
}
}
#
# Reference
#
output "connection" {
description = "The connection, a string combined host and port, might be a comma separated string or a single string."
value = join(",", local.endpoints)
}
output "connection_readonly" {
description = "The readonly connection, a string combined host and port, might be a comma separated string or a single string."
value = join(",", local.endpoints_readonly)
}
output "address" {
description = "The address, a string only has host, might be a comma separated string or a single string."
value = join(",", local.hosts)
}
output "address_readonly" {
description = "The readonly address, a string only has host, might be a comma separated string or a single string."
value = join(",", local.hosts_readonly)
}
output "port" {
description = "The port of the PostgreSQL service."
value = 5432
}
output "database" {
description = "The name of PostgreSQL database to access."
value = local.database
}
output "username" {
description = "The username of the account to access the database."
value = local.username
}
output "password" {
value = local.password
description = "The password of the account to access the database."
sensitive = true
}