-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcert.tf
37 lines (31 loc) · 1.43 KB
/
cert.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
data "ns_connection" "certificate" {
name = "certificate"
contract = "block/gcp/certificate-manager"
optional = true
}
locals {
ext_certificate_id = try(data.ns_connection.certificate.outputs.certificate_id, "")
ext_certificate_map_id = try(data.ns_connection.certificate.outputs.certificate_map_id, "")
ext_certificate_map_name = try(data.ns_connection.certificate.outputs.certificate_map_name, "")
ext_certificate_domains = try(data.ns_connection.certificate.outputs.certificate_domains, [])
create_cert = !var.disable_certificate && local.ext_certificate_map_id == ""
}
// If user specifies "certificate" connection, we use that certificate
// Otherwise, we use var.disable_certificate to determine if we should create a certificate
module "cert" {
source = "nullstone-modules/sslcert/gcp"
version = "~> 0.1.0"
enabled = local.create_cert
name = local.resource_name
labels = local.labels
scope = ""
subdomains = {
(local.subdomain_name) = local.subdomain_zone_id
}
}
locals {
certificate_id = coalesce(local.ext_certificate_id, module.cert.certificate_id)
certificate_map_id = coalesce(local.ext_certificate_map_id, module.cert.certificate_map_id)
certificate_map_name = coalesce(local.ext_certificate_map_name, module.cert.certificate_map_name)
certificate_domains = coalesce(local.ext_certificate_domains, module.cert.certificate_domains)
}