-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathecs_task.tf
59 lines (58 loc) · 1.7 KB
/
ecs_task.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
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition
resource "aws_ecs_task_definition" "web_app" {
family = var.name
execution_role_arn = aws_iam_role.ecs_task_execution_role.arn
task_role_arn = aws_iam_role.ecs_task_role.arn
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = "1024"
memory = "3072"
runtime_platform {
operating_system_family = "LINUX"
cpu_architecture = "X86_64"
}
container_definitions = jsonencode([
{
name = "first"
image = var.image_tag
memory = 512
essential = true
readonlyRootFilesystem = true
portMappings = [
{
containerPort = 8080
hostPort = 8080
protocol = "tcp"
appProtocol = "http"
}
]
logConfiguration = {
logDriver = "awslogs"
options = {
awslogs-group = local.infra_output["aws_cloudwatch_log_group_name"]
awslogs-region = var.region
awslogs-stream-prefix = "ecs"
}
}
healthCheck = {
command = ["CMD-SHELL", "curl -f http://localhost:8080/healthcheck>> /proc/1/fd/1 2>&1 || exit 1"]
interval = 30
retries = 3
timeout = 5
startPeriod = 10
}
environments = [
{
name = "AWS_REGION",
value = var.region
}
]
secrets = [
{
name = "ecs_secret"
valueFrom = local.infra_output["secret_arn"]
}
]
}
])
}