-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecs.tf
61 lines (49 loc) · 1.7 KB
/
ecs.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
resource "aws_ecs_cluster" "_" {
name = local.ecs_name_cluster
}
resource "aws_ecs_task_definition" "_" {
family = local.ecs_name_task_definition
container_definitions = data.template_file.task_definition.rendered
requires_compatibilities = ["FARGATE"]
cpu = var.ecs_cpu
memory = var.ecs_memory
network_mode = "awsvpc"
task_role_arn = local.ecs_role_arn
execution_role_arn = local.ecs_role_arn
}
resource "aws_ecs_service" "_" {
name = local.ecs_name_service
cluster = aws_ecs_cluster._.id
task_definition = aws_ecs_task_definition._.arn
launch_type = "FARGATE"
desired_count = var.desired_count
deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent
network_configuration {
security_groups = [aws_security_group.alb_ecs[0].id]
subnets = var.subnets
assign_public_ip = true
}
load_balancer {
target_group_arn = aws_alb_target_group._[0].arn
container_name = local.ecs_name_task_definition
container_port = var.container_port
}
depends_on = [
aws_alb_listener._,
]
count = local.alb_count
}
resource "aws_ecs_service" "no_alb" {
name = local.ecs_name_service
cluster = aws_ecs_cluster._.id
task_definition = aws_ecs_task_definition._.arn
launch_type = "FARGATE"
desired_count = var.desired_count
deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent
network_configuration {
security_groups = var.security_groups
subnets = var.subnets
assign_public_ip = true
}
count = local.alb_count == 1 ? 0 : 1
}