Skip to content

Commit

Permalink
feat: add EBS volume
Browse files Browse the repository at this point in the history
  • Loading branch information
Isobel Daley authored and Isobel Daley committed Apr 11, 2024
1 parent 4a3b62d commit 1e23406
Showing 1 changed file with 38 additions and 10 deletions.
48 changes: 38 additions & 10 deletions infra/ecs_main_arango.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ resource "aws_autoscaling_group" "arango_service" {
}
}

data "aws_autoscaling_groups" "arango_asgs" {
names = ["${aws_autoscaling_group.arango_service.name}"]
}

resource "aws_launch_template" "arango_service" {
name_prefix = "${var.prefix}-arango-service-"
image_id = "ami-0c618421e207909d0"
Expand Down Expand Up @@ -100,9 +104,14 @@ data "template_file" "ecs_config_template" {
vars = {
ECS_CLUSTER = "${aws_ecs_cluster.main_cluster.name}"
EBS_REGION = "${data.aws_region.aws_region.name}"
EBS_VOLUME_ID = "${aws_ebs_volume.arango.id}"
}
}

output "rendered" {
value = "${data.template_file.ecs_config_template.rendered}"
}

resource "aws_ecs_capacity_provider" "arango_capacity_provider" {
name = "${var.prefix}-arango_service"

Expand Down Expand Up @@ -138,6 +147,12 @@ resource "aws_ecs_task_definition" "arango_service" {
memory = "${local.arango_container_memory}"
requires_compatibilities = ["EC2"]

volume {
name = "data-arango"
host_path = "/data/"
}


lifecycle {
ignore_changes = [
"revision",
Expand All @@ -158,6 +173,21 @@ data "template_file" "arango_service_container_definitions" {
}
}

resource "aws_ebs_volume" "arango" {
availability_zone = var.aws_availability_zones[0]
size = 20
type = "gp3"
encrypted = true

lifecycle {
prevent_destroy = false
}

tags = {
Name = "${var.prefix}-arango"
}
}

resource "aws_cloudwatch_log_group" "arango" {
name = "${var.prefix}-arango"
retention_in_days = "3653"
Expand Down Expand Up @@ -338,15 +368,13 @@ resource "aws_iam_instance_profile" "arango_ec2" {

resource "aws_lb" "arango" {
name = "${var.prefix}-arango"
load_balancer_type = "network"
load_balancer_type = "application"
security_groups = ["${aws_security_group.arango_lb.id}"]
enable_deletion_protection = false
enable_deletion_protection = true
internal = true
subnets = aws_subnet.datasets.*.id
timeouts {}

subnet_mapping {
subnet_id = "${aws_subnet.datasets.*.id[0]}"
}

tags = {
name = "arango-to-notebook-lb"
}
Expand All @@ -355,7 +383,7 @@ resource "aws_lb" "arango" {
resource "aws_lb_listener" "arango" {
load_balancer_arn = "${aws_lb.arango.arn}"
port = "8529"
protocol = "TCP"
protocol = "HTTP"

default_action {
target_group_arn = "${aws_lb_target_group.arango.id}"
Expand All @@ -368,13 +396,13 @@ resource "aws_lb_target_group" "arango" {
port = "8529"
vpc_id = "${aws_vpc.datasets.id}"
target_type = "ip"
protocol = "TCP"
preserve_client_ip = true
protocol = "HTTP"

health_check {
protocol = "TCP"
protocol = "HTTP"
interval = 10
healthy_threshold = 2
unhealthy_threshold = 2
path = "/_db/_system/_admin/aardvark/index.html"
}
}

0 comments on commit 1e23406

Please sign in to comment.