-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdns.tf
33 lines (27 loc) · 865 Bytes
/
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
variable "create_dns" {
description = "Bool to create ssl cert and nginx proxy"
type = bool
default = true
}
variable "domain_name" {
description = "The domain - example.com. Blank for no ssl / nginx"
type = string
default = ""
}
variable "hostname" {
description = "The hostname - ie hostname.example.com"
type = string
default = "airflow"
}
data "aws_route53_zone" "this" {
count = var.domain_name != "" && var.create_dns ? 1 : 0
name = var.domain_name
}
resource "aws_route53_record" "this" {
count = var.domain_name != "" && var.hostname != "" && var.create_dns ? 1 : 0
name = var.hostname == "" ? var.domain_name : "${var.hostname}.${var.domain_name}"
type = "A"
ttl = "300"
zone_id = join("", data.aws_route53_zone.this.*.id)
records = [join("", aws_eip.this.*.public_ip)]
}