From 30eba0e8da2a8a44040271c442c4e3017c293b07 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 20 Dec 2023 10:02:03 +0200 Subject: add --- org-buetow-nextcloud/data.tf | 3 +++ org-buetow-nextcloud/lb.tf | 46 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 org-buetow-nextcloud/data.tf create mode 100644 org-buetow-nextcloud/lb.tf (limited to 'org-buetow-nextcloud') diff --git a/org-buetow-nextcloud/data.tf b/org-buetow-nextcloud/data.tf new file mode 100644 index 0000000..3a8f86c --- /dev/null +++ b/org-buetow-nextcloud/data.tf @@ -0,0 +1,3 @@ +data "aws_route53_zone" "my_zone" { + name = "aws.buetow.org." # Replace with your domain name +} diff --git a/org-buetow-nextcloud/lb.tf b/org-buetow-nextcloud/lb.tf new file mode 100644 index 0000000..49ba6dd --- /dev/null +++ b/org-buetow-nextcloud/lb.tf @@ -0,0 +1,46 @@ +resource "aws_route53_record" "my_a_record" { + zone_id = data.aws_route53_zone.my_zone.zone_id + name = "nextcloud.aws.buetow.org." + type = "A" + + alias { + name = data.terraform_remote_state.elb.outputs.alb_dns_name + zone_id = data.terraform_remote_state.elb.outputs.alb_zone_id + evaluate_target_health = true + } +} + +resource "aws_lb_target_group" "nextcloud_tg" { + name = "nextcloud-tg" + port = 80 + protocol = "HTTP" + vpc_id = data.terraform_remote_state.base.outputs.my_vpc_id + target_type = "ip" + + health_check { + enabled = true + healthy_threshold = 2 + unhealthy_threshold = 2 + interval = 30 + path = "/" # Modify if your app has a specific health check path + protocol = "HTTP" + timeout = 3 + matcher = "200-299" + } +} + +resource "aws_lb_listener_rule" "nextcloud_https_listener_rule" { + listener_arn = data.terraform_remote_state.elb.outputs.alb_https_listener_arn + priority = 200 + + action { + type = "forward" + target_group_arn = aws_lb_target_group.nextcloud_tg.arn + } + + condition { + host_header { + values = ["nextcloud.aws.buetow.org"] + } + } +} -- cgit v1.2.3