-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathecs.tf
62 lines (57 loc) · 1.65 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
62
resource "aws_ecs_cluster" "web-cluster" {
name = var.cluster_name
capacity_providers = [aws_ecs_capacity_provider.test.name]
tags = {
"env" = "dev"
"createdBy" = "mkerimova"
}
}
resource "aws_ecs_capacity_provider" "test" {
name = "capacity-provider-test"
auto_scaling_group_provider {
auto_scaling_group_arn = aws_autoscaling_group.asg.arn
managed_termination_protection = "ENABLED"
managed_scaling {
status = "ENABLED"
target_capacity = 85
}
}
}
# update file container-def, so it's pulling image from ecr
resource "aws_ecs_task_definition" "task-definition-test" {
family = "web-family"
container_definitions = file("container-definitions/container-def.json")
network_mode = "bridge"
tags = {
"env" = "dev"
"createdBy" = "mkerimova"
}
}
resource "aws_ecs_service" "service" {
name = "web-service"
cluster = aws_ecs_cluster.web-cluster.id
task_definition = aws_ecs_task_definition.task-definition-test.arn
desired_count = 10
ordered_placement_strategy {
type = "binpack"
field = "cpu"
}
load_balancer {
target_group_arn = aws_lb_target_group.lb_target_group.arn
container_name = "pink-slon"
container_port = 80
}
# Optional: Allow external changes without Terraform plan difference(for example ASG)
lifecycle {
ignore_changes = [desired_count]
}
launch_type = "EC2"
depends_on = [aws_lb_listener.web-listener]
}
resource "aws_cloudwatch_log_group" "log_group" {
name = "/ecs/frontend-container"
tags = {
"env" = "dev"
"createdBy" = "mkerimova"
}
}