forked from chainguard-dev/registry-redirect
-
Notifications
You must be signed in to change notification settings - Fork 3
/
new_cert.tf
53 lines (42 loc) · 1.22 KB
/
new_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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
variable "new_domains" {
type = list(string)
default = [
"cgr.dev",
"distroless.dev",
"images.wolfi.dev",
]
}
// Enable Certificate Manager API.
resource "google_project_service" "certmanager" {
service = "certificatemanager.googleapis.com"
}
resource "google_certificate_manager_dns_authorization" "this" {
for_each = toset(var.new_domains)
name = replace("${each.key}", ".", "-")
domain = each.key
labels = {}
}
resource "google_certificate_manager_certificate" "cert" {
for_each = toset(var.new_domains)
name = replace("${each.key}", ".", "-")
scope = "DEFAULT"
managed {
domains = [each.key]
dns_authorizations = [
google_certificate_manager_dns_authorization.this[each.key].id
]
}
depends_on = [google_project_service.certmanager]
}
resource "google_certificate_manager_certificate_map" "map" {
name = "cert-map"
}
resource "google_certificate_manager_certificate_map_entry" "map_entry" {
for_each = toset(var.new_domains)
name = replace("certificatemapentry-${each.key}", ".", "-")
map = google_certificate_manager_certificate_map.map.name
hostname = each.key
certificates = [
google_certificate_manager_certificate.cert[each.key].id
]
}