-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecs.tf
50 lines (45 loc) · 1.66 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
resource "aws_ecs_cluster" "main" {
name = "cyberchef-cluster"
}
# Cyberchef Service
resource "aws_ecs_task_definition" "cyberchef" {
family = "${local.name_prefix}-task-def"
execution_role_arn = aws_iam_role.ecs_task_execution_role.arn
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = var.fargate_cpu
memory = var.fargate_memory
container_definitions = templatefile("${path.module}/templates/ecs/cyberchef.json.tpl",
{
app_image = var.app_image
host_port = var.host_port
container_port = var.container_port
fargate_cpu = var.fargate_cpu
fargate_memory = var.fargate_memory
aws_region = var.aws_region
cloudwatch_group = local.name_prefix
env = var.env
}
)
}
resource "aws_ecs_service" "cyberchef" {
name = "${local.name_prefix}-service"
cluster = aws_ecs_cluster.main.id
task_definition = aws_ecs_task_definition.cyberchef.arn
desired_count = var.app_count
launch_type = "FARGATE"
health_check_grace_period_seconds = 60
network_configuration {
security_groups = [aws_security_group.ecs.id]
subnets = var.create_vpc == true ? aws_subnet.private.*.id : var.private_subnet_ids
}
load_balancer {
target_group_arn = aws_alb_target_group.cyberchef.arn
container_name = "cyberchef"
container_port = var.container_port
}
depends_on = [
aws_alb_listener.front_end,
aws_iam_role_policy_attachment.attach_task_execution
]
}