-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecs-task-definitions.tf
92 lines (85 loc) · 2.42 KB
/
ecs-task-definitions.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
resource "aws_ecs_task_definition" "jenkins_master" {
family = var.ecs_task_definitions_name
task_role_arn = aws_iam_role.jenkins_ecs_role.arn
execution_role_arn = aws_iam_role.jenkins_ecs_role.arn
network_mode = "awsvpc"
requires_compatibilities = [
"FARGATE"
]
cpu = var.jenkins_master_cpu_size
memory = var.jenkins_master_memory_size
volume {
name = "jenkins_home"
# use efs directly, this way must be run container as root user.
# ref: https://stackoverflow.com/questions/61967965/how-to-run-nonroot-user-in-ecs
/* efs_volume_configuration {
file_system_id = var.efs_id
root_directory = "/"
} */
# use efs access point.
efs_volume_configuration {
file_system_id = aws_efs_file_system.jenkins_ecs.id
transit_encryption = "ENABLED"
transit_encryption_port = 2999
root_directory = "/"
authorization_config {
access_point_id = aws_efs_access_point.jenkins_master.id
iam = "ENABLED"
}
}
}
container_definitions = jsonencode(
[
{
"name" : "jenkins-master",
"image" : var.jenkins_master_image,
"cpu" : var.jenkins_master_cpu_size,
"memory" : var.jenkins_master_memory_size,
"portMappings" : [
{
"containerPort" : 8080,
"hostPort" : 8080,
"protocol" : "tcp"
},
{
"containerPort" : 50000,
"hostPort" : 50000,
"protocol" : "tcp"
}
],
"essential" : true,
"environment" : [],
"mountPoints" : [
{
"sourceVolume" : "jenkins_home",
"containerPath" : "/var/jenkins_home"
}
],
"logConfiguration" : {
"logDriver" : "awslogs",
"options" : {
"awslogs-group" : "/aws/ecs/${var.ecs_cluster_name}/${var.ecs_service_name}"
"awslogs-region" : var.region,
"awslogs-stream-prefix" : var.ecs_service_name
}
},
"healthCheck" : {
"command" : [
"CMD-SHELL",
"curl -f http://localhost:8080/login || exit 1"
],
"interval" : 30,
"timeout" : 5,
"retries" : 3,
"startPeriod" : 120
}
}
]
)
tags = merge(
var.tags
)
depends_on = [
aws_ecs_cluster.jenkins
]
}