-
Notifications
You must be signed in to change notification settings - Fork 0
/
outputs.tf
139 lines (124 loc) · 5.3 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
locals {
grouped_resources = {
for p in var.drupal_projects_list : "${p.project_name}-${p.gitlab_project_id}-${p.release_branch_name}" => p...
}
all_data = {
for key, resources in local.grouped_resources : key => {
for r in resources : (r.helm_release_name != null ? r.helm_release_name : "drupal-${r.release_branch_name}-${r.gitlab_project_id}") => {
namespace = r.kubernetes_namespace == null ? "${r.project_name}-${r.gitlab_project_id}-${r.release_branch_name}" : r.kubernetes_namespace
bucket_credentials = try(module.drupal_buckets[0].buckets_access_credentials["${r.project_name}-${r.gitlab_project_id}-${r.release_branch_name}-drupal"], null)
database_credentials = try(
[for cred in module.drupal_databases_and_users[0].sql_users_creds : cred
if cred.database == (
r.database_name != null ?
r.database_name :
replace("${r.project_name}_${r.gitlab_project_id}_${r.release_branch_name}_dp", "-", "_")
)][0], null)
kubernetes_bucket_secret = try(local.bucket_secrets_map["${r.project_name}-${r.gitlab_project_id}-${r.release_branch_name}"], null)
kubernetes_database_secret = try(local.database_secrets_map["${r.project_name}-${r.gitlab_project_id}-${r.release_branch_name}-${r.helm_release_name != null ? r.helm_release_name : "drupal-${r.release_branch_name}-${r.gitlab_project_id}"}"], null)
}
}
}
bucket_secrets_map = var.create_buckets ? {
for o in local.drupal_buckets_list : replace(o.name, "-drupal", "") => {
secret_name = try(
kubernetes_secret.bucket_secret_name[o.name].metadata[0].name,
null
)
namespace = try(
kubernetes_secret.bucket_secret_name[o.name].metadata[0].namespace,
null
)
}
} : {}
database_secrets_map = {
for p in var.drupal_projects_list : "${p.project_name}-${p.gitlab_project_id}-${p.release_branch_name}-${p.helm_release_name != null ? p.helm_release_name : "drupal-${p.release_branch_name}-${p.gitlab_project_id}"}" => {
secret_name = try(
kubernetes_secret.database_secret_name[
p.helm_release_name != null ? p.helm_release_name : replace("${p.project_name}_${p.gitlab_project_id}_${p.release_branch_name}_dp", "-", "_")
].metadata[0].name,
null
)
namespace = try(
kubernetes_secret.database_secret_name[
p.helm_release_name != null ? p.helm_release_name : replace("${p.project_name}_${p.gitlab_project_id}_${p.release_branch_name}_dp", "-", "_")
].metadata[0].namespace,
null
)
}
}
}
output "drupal_apps_all_data" {
description = "All data for each Drupal project."
value = local.all_data
}
output "drupal_apps_all_namespaces" {
description = "Map of all Kubernetes namespaces used by Drupal apps, indexed same as all_data"
value = {
for key, values in local.all_data : key => {
for helm_release, data in values : helm_release => data.namespace
}
}
}
output "drupal_apps_all_bucket_credentials" {
description = "Bucket credentials for each Drupal project, indexed same as all_data"
sensitive = true
value = {
for key, values in local.all_data : key => {
for helm_release, data in values : helm_release => data.bucket_credentials
}
}
}
output "drupal_apps_all_bucket_secrets" {
description = "Bucket kubernetes secrets for each Drupal project, indexed same as all_data"
sensitive = true
value = {
for key, values in local.all_data : key => {
for helm_release, data in values : helm_release => data.kubernetes_bucket_secret
}
}
}
output "drupal_apps_all_database_credentials" {
description = "Database credentials for each Drupal project, indexed same as all_data"
sensitive = true
value = {
for key, values in local.all_data : key => {
for helm_release, data in values : helm_release => data.database_credentials
}
}
}
output "drupal_apps_all_database_secrets" {
description = "Database kubernetes secrets for each Drupal project, indexed same as all_data"
sensitive = true
value = {
for key, values in local.all_data : key => {
for helm_release, data in values : helm_release => data.kubernetes_database_secret
}
}
}
output "drupal_apps_database_credentials" {
sensitive = true
description = "Drupal apps database credentials for each Drupal project."
value = toset(module.drupal_databases_and_users[*].sql_users_creds)
}
output "drupal_apps_bucket_credentials" {
sensitive = true
description = "Drupal apps bucket credentials for each Drupal project."
value = module.drupal_buckets[*].buckets_access_credentials
}
output "details_of_used_tag_keys" {
description = "Details of the tag keys passed to this module."
value = module.drupal_buckets[*].details_of_used_tag_keys
}
output "details_of_used_tag_values" {
description = "Details of the tag values passed to this module."
value = module.drupal_buckets[*].details_of_used_tag_values
}
output "drupal_buckets_names_list" {
description = "The list with the names of the Drupal buckets managed by this module."
value = flatten(module.drupal_buckets[*].generated_bucket_names)
}
output "cloudsql_dumps_bucket_name" {
description = "CloudSQL dumps bucket name."
value = local.cloudsql_dumps_bucket_name
}