summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-12-20 10:02:03 +0200
committerPaul Buetow <paul@buetow.org>2023-12-20 10:02:03 +0200
commit30eba0e8da2a8a44040271c442c4e3017c293b07 (patch)
tree1e85a781efae35f982b130d4be1152ea67fe7e1f
parent999bddddc8354c5665c660290b99e1cf446edb2f (diff)
add
-rw-r--r--org-buetow-nextcloud/data.tf3
-rw-r--r--org-buetow-nextcloud/lb.tf46
2 files changed, 49 insertions, 0 deletions
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"]
+ }
+ }
+}