-
Notifications
You must be signed in to change notification settings - Fork 4
/
elastic-container-service.tf
42 lines (36 loc) · 1.25 KB
/
elastic-container-service.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
resource "aws_ecs_cluster" "ecs-cluster_nexus" {
name = "${var.cluster-name}"
}
resource "aws_appautoscaling_target" "ecs-as-target_nexus" {
max_capacity = 5
min_capacity = 1
resource_id = "service/${aws_ecs_cluster.ecs-cluster_nexus.name}/${aws_ecs_service.ecs-service_nexus.name}"
role_arn = "${aws_iam_role.iam_nexus-ecs-role.arn}"
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
}
resource "aws_ecs_task_definition" "ecs-tf_nexus" {
family = "nexus-node"
container_definitions = "${file("${path.module}/custom/task-definition/nexus.json")}"
network_mode = "bridge"
volume = {
name = "nexus-data"
host_path = "/data"
}
}
resource "aws_ecs_service" "ecs-service_nexus" {
name = "nexus-service"
cluster = "${aws_ecs_cluster.ecs-cluster_nexus.arn}"
task_definition = "${aws_ecs_task_definition.ecs-tf_nexus.arn}"
desired_count = 2
iam_role = "${aws_iam_role.iam_nexus-ecs-role.id}"
load_balancer {
target_group_arn = "${aws_alb_target_group.alb-tg-nexus.id}"
container_name = "nexus-node"
container_port = 8081
}
depends_on = [
"aws_alb_target_group.alb-tg-nexus",
"aws_alb.alb-nexus",
]
}