summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-12-18 22:12:24 +0200
committerPaul Buetow <paul@buetow.org>2023-12-18 22:12:24 +0200
commit7fd1d95501235b9a9c2fcc19d8b313a840db89d9 (patch)
treed7dd12ac30fd6a60c32132b3af92cf7cfdf13457
parentb887e2a1f77e5694d20f59703500a15b90e378b9 (diff)
add vaultwarden
-rw-r--r--org-buetow-ecs/audiobookshelfservice.tf2
-rw-r--r--org-buetow-ecs/nginxservice.tf2
-rw-r--r--org-buetow-ecs/vaultwarden.tf111
-rw-r--r--org-buetow-ecs/wallabagservice.tf2
4 files changed, 114 insertions, 3 deletions
diff --git a/org-buetow-ecs/audiobookshelfservice.tf b/org-buetow-ecs/audiobookshelfservice.tf
index 50290df..50358f0 100644
--- a/org-buetow-ecs/audiobookshelfservice.tf
+++ b/org-buetow-ecs/audiobookshelfservice.tf
@@ -91,7 +91,7 @@ resource "aws_ecs_task_definition" "audiobookshelf_task" {
}
resource "aws_ecs_service" "audiobookshelf_service" {
- name = "audiobookshelf-service"
+ name = "audiobookshelf"
cluster = aws_ecs_cluster.my_ecs_cluster.id
task_definition = aws_ecs_task_definition.audiobookshelf_task.arn
launch_type = "FARGATE"
diff --git a/org-buetow-ecs/nginxservice.tf b/org-buetow-ecs/nginxservice.tf
index 0477da1..1ea519b 100644
--- a/org-buetow-ecs/nginxservice.tf
+++ b/org-buetow-ecs/nginxservice.tf
@@ -37,7 +37,7 @@ resource "aws_ecs_task_definition" "nginx_task" {
}
resource "aws_ecs_service" "nginx_service" {
- name = "nginx-service"
+ name = "nginx"
cluster = aws_ecs_cluster.my_ecs_cluster.id
task_definition = aws_ecs_task_definition.nginx_task.arn
launch_type = "FARGATE"
diff --git a/org-buetow-ecs/vaultwarden.tf b/org-buetow-ecs/vaultwarden.tf
new file mode 100644
index 0000000..4346218
--- /dev/null
+++ b/org-buetow-ecs/vaultwarden.tf
@@ -0,0 +1,111 @@
+resource "aws_route53_record" "my_a_record_vaultwarden" {
+ zone_id = data.aws_route53_zone.my_zone.zone_id
+ name = "vaultwarden.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_ecs_task_definition" "vaultwarden_task" {
+ family = "vaultwarden"
+ network_mode = "awsvpc"
+ requires_compatibilities = ["FARGATE"]
+ cpu = "256"
+ memory = "512"
+ execution_role_arn = aws_iam_role.ecs_execution_role.arn
+
+ volume {
+ name = "vaultwarden-data-efs-volume"
+ efs_volume_configuration {
+ file_system_id = data.terraform_remote_state.base.outputs.my_self_hosted_services_efs_id
+ root_directory = "/ecs/vaultwarden/data"
+ }
+ }
+
+ container_definitions = jsonencode([{
+ name = "vaultwarden",
+ image = "vaultwarden/server:latest",
+ portMappings = [{
+ containerPort = 80,
+ hostPort = 80
+ }],
+ mountPoints = [
+ {
+ sourceVolume = "vaultwarden-data-efs-volume"
+ containerPath = "/data"
+ readOnly = false
+ }
+ ],
+ "logConfiguration" : {
+ "logDriver" : "awslogs",
+ "options" : {
+ "awslogs-group" : "/ecs/containers",
+ "awslogs-region" : "eu-central-1",
+ "awslogs-stream-prefix" : "vaultwarden"
+ }
+ }
+ }])
+}
+
+resource "aws_ecs_service" "vaultwarden_service" {
+ name = "vaultwarden"
+ cluster = aws_ecs_cluster.my_ecs_cluster.id
+ task_definition = aws_ecs_task_definition.vaultwarden_task.arn
+ launch_type = "FARGATE"
+ desired_count = 0
+
+ load_balancer {
+ target_group_arn = aws_lb_target_group.my_vaultwarden_tg.arn
+ container_name = "vaultwarden" # Must match the name in your container definition
+ container_port = 80 # The port your container is listening on
+ }
+
+ network_configuration {
+ subnets = [
+ data.terraform_remote_state.base.outputs.my_public_subnet_a_id,
+ data.terraform_remote_state.base.outputs.my_public_subnet_b_id,
+ data.terraform_remote_state.base.outputs.my_public_subnet_c_id,
+ ]
+ security_groups = [data.terraform_remote_state.base.outputs.allow_web_sg_id]
+ assign_public_ip = true
+ }
+}
+
+resource "aws_lb_target_group" "my_vaultwarden_tg" {
+ name = "my-vaultwarden-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 = "/"
+ protocol = "HTTP"
+ timeout = 3
+ matcher = "200-299"
+ }
+}
+
+resource "aws_lb_listener_rule" "my_vaultwarden_https_listener_rule" {
+ listener_arn = aws_lb_listener.my_https_listener.arn
+ priority = 103
+
+ action {
+ type = "forward"
+ target_group_arn = aws_lb_target_group.my_vaultwarden_tg.arn
+ }
+
+ condition {
+ host_header {
+ values = ["vaultwarden.aws.buetow.org"]
+ }
+ }
+}
diff --git a/org-buetow-ecs/wallabagservice.tf b/org-buetow-ecs/wallabagservice.tf
index 90f9626..e8cb8ac 100644
--- a/org-buetow-ecs/wallabagservice.tf
+++ b/org-buetow-ecs/wallabagservice.tf
@@ -74,7 +74,7 @@ resource "aws_ecs_task_definition" "wallabag_task" {
}
resource "aws_ecs_service" "wallabag_service" {
- name = "wallabag-service"
+ name = "wallabag"
cluster = aws_ecs_cluster.my_ecs_cluster.id
task_definition = aws_ecs_task_definition.wallabag_task.arn
launch_type = "FARGATE"