From 2330898cf8cc6a79d2ca24582eed9ea9694d4466 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 17 Dec 2023 16:55:24 +0200 Subject: add ELB DNS --- playground/fargate/elb.tf | 54 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/playground/fargate/elb.tf b/playground/fargate/elb.tf index e2f5f98..d589e03 100644 --- a/playground/fargate/elb.tf +++ b/playground/fargate/elb.tf @@ -3,7 +3,7 @@ resource "aws_lb" "my_alb" { internal = false load_balancer_type = "application" security_groups = [aws_security_group.alb_sg.id] - subnets = [ + subnets = [ aws_subnet.my_public_subnet_a.id, aws_subnet.my_public_subnet_b.id, aws_subnet.my_public_subnet_c.id, @@ -31,10 +31,10 @@ resource "aws_security_group" "alb_sg" { } resource "aws_lb_target_group" "my_tg" { - name = "my-tg" - port = 80 - protocol = "HTTP" - vpc_id = aws_vpc.my_vpc.id + name = "my-tg" + port = 80 + protocol = "HTTP" + vpc_id = aws_vpc.my_vpc.id target_type = "ip" health_check { @@ -42,14 +42,14 @@ resource "aws_lb_target_group" "my_tg" { healthy_threshold = 2 unhealthy_threshold = 2 interval = 30 - path = "/" # Modify if your app has a specific health check path + path = "/" # Modify if your app has a specific health check path protocol = "HTTP" timeout = 3 matcher = "200-299" } } -resource "aws_lb_listener" "my_listener" { +resource "aws_lb_listener" "my_http_listener" { load_balancer_arn = aws_lb.my_alb.arn port = "80" protocol = "HTTP" @@ -60,3 +60,43 @@ resource "aws_lb_listener" "my_listener" { } } +data "aws_route53_zone" "my_zone" { + name = "aws.buetow.org." +} + +resource "aws_route53_record" "my_a_record" { + zone_id = data.aws_route53_zone.my_zone.zone_id + name = "nginx.aws.buetow.org." + type = "A" + + alias { + name = aws_lb.my_alb.dns_name + zone_id = aws_lb.my_alb.zone_id + evaluate_target_health = true + } +} + +#resource "aws_route53_record" "my_aaaa_record" { +# zone_id = data.aws_route53_zone.my_zone.zone_id +# name = "nginx.aws.buetow.org." +# type = "AAAA" +# +# alias { +# name = aws_lb.my_alb.dns_name +# zone_id = aws_lb.my_alb.zone_id +# evaluate_target_health = true +# } +#} + + +#resource "aws_lb_listener" "my_https_listener" { +# load_balancer_arn = aws_lb.my_alb.arn +# port = "443" +# protocol = "HTTPS" +# +# default_action { +# type = "forward" +# target_group_arn = aws_lb_target_group.my_tg.arn +# } +#} + -- cgit v1.2.3