-
Notifications
You must be signed in to change notification settings - Fork 90
/
ingress.tf
65 lines (52 loc) · 1.3 KB
/
ingress.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
resource "kubernetes_service" "current" {
provider = kubernetes.eks
metadata {
name = "ingress-kbst-default"
namespace = "ingress-kbst-default"
}
spec {
type = "LoadBalancer"
selector = {
"kubestack.com/ingress-default" = "true"
}
port {
name = "http"
port = 80
target_port = "http"
}
port {
name = "https"
port = 443
target_port = "https"
}
}
depends_on = [module.cluster_services]
}
resource "aws_route53_zone" "current" {
name = "${var.metadata_fqdn}."
}
locals {
elb_hostname = kubernetes_service.current.load_balancer_ingress[0].hostname
}
data "aws_elb_hosted_zone_id" "current" {
}
resource "aws_route53_record" "host" {
zone_id = aws_route53_zone.current.zone_id
name = var.metadata_fqdn
type = "A"
alias {
name = local.elb_hostname
zone_id = data.aws_elb_hosted_zone_id.current.id
evaluate_target_health = true
}
}
resource "aws_route53_record" "wildcard" {
zone_id = aws_route53_zone.current.zone_id
name = "*.${var.metadata_fqdn}"
type = "A"
alias {
name = local.elb_hostname
zone_id = data.aws_elb_hosted_zone_id.current.id
evaluate_target_health = true
}
}