-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathecs-nginx.tf
56 lines (49 loc) · 1.13 KB
/
ecs-nginx.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
# NGINX Service
resource "aws_ecs_service" "nginx" {
name = "nginx"
cluster = aws_ecs_cluster.demo.id
task_definition = aws_ecs_task_definition.nginx.arn
desired_count = 4
iam_role = aws_iam_role.ecs-service-role.arn
depends_on = [aws_iam_role_policy_attachment.ecs-service-attach]
load_balancer {
target_group_arn = aws_alb_target_group.nginx.id
container_name = "nginx"
container_port = "80"
}
lifecycle {
ignore_changes = [task_definition]
}
}
resource "aws_ecs_task_definition" "nginx" {
family = "nginx"
container_definitions = <<EOF
[
{
"portMappings": [
{
"hostPort": 0,
"protocol": "tcp",
"containerPort": 80
}
],
"cpu": 256,
"memory": 300,
"image": "nginx:latest",
"essential": true,
"name": "nginx",
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs-demo/nginx",
"awslogs-region": "eu-west-2",
"awslogs-stream-prefix": "ecs"
}
}
}
]
EOF
}
resource "aws_cloudwatch_log_group" "nginx" {
name = "/ecs-demo/nginx"
}