-
Notifications
You must be signed in to change notification settings - Fork 0
/
dns.tf
78 lines (69 loc) · 2.18 KB
/
dns.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
resource "google_dns_managed_zone" "project-zone" {
project = var.project_id
name = "${var.prefix}-zone"
dns_name = "${var.prefix}.${var.external_domain}."
description = "DNS zone for cloud projects"
}
data "google_dns_managed_zone" "parent-zone" {
project = var.parent_dns_project_id
name = var.parent_dns_zone_name
}
resource "google_dns_record_set" "projects-ns" {
depends_on = [
google_dns_managed_zone.project-zone
]
project = var.parent_dns_project_id
name = "${var.prefix}.${var.external_domain}."
managed_zone = data.google_dns_managed_zone.parent-zone.name
type = "NS"
ttl = 300
rrdatas = google_dns_managed_zone.project-zone.name_servers
}
resource "google_dns_record_set" "a-hc" {
name = "gcp.${var.prefix}.${var.external_domain}."
managed_zone = "${var.prefix}-zone"
type = "A"
ttl = 300
rrdatas = [google_compute_global_forwarding_rule.global_forwarding_rule.ip_address]
}
resource "google_dns_record_set" "cname-vault" {
depends_on = [
google_dns_record_set.a-hc
]
name = "vault.${var.prefix}.${var.external_domain}."
managed_zone = "${var.prefix}-zone"
type = "CNAME"
ttl = 30
rrdatas = [google_dns_record_set.a-hc.name]
}
resource "google_dns_record_set" "cname-consul" {
depends_on = [
google_dns_record_set.a-hc
]
name = "consul.${var.prefix}.${var.external_domain}."
managed_zone = "${var.prefix}-zone"
type = "CNAME"
ttl = 30
rrdatas = [google_dns_record_set.a-hc.name]
}
resource "google_dns_record_set" "cname-nomad" {
count = var.enable_nomad ? 1 : 0
depends_on = [
google_dns_record_set.a-hc
]
name = "nomad.${var.prefix}.${var.external_domain}."
managed_zone = "${var.prefix}-zone"
type = "CNAME"
ttl = 30
rrdatas = [google_dns_record_set.a-hc.name]
}
resource "google_dns_record_set" "cname-wild" {
depends_on = [
google_dns_record_set.a-hc
]
name = "*.${var.prefix}.${var.external_domain}."
managed_zone = "${var.prefix}-zone"
type = "CNAME"
ttl = 30
rrdatas = [google_dns_record_set.a-hc.name]
}