-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathservices.tf
51 lines (50 loc) · 1.75 KB
/
services.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
resource "aws_ecs_service" "this" {
for_each = var.ecs_services
name = "${each.key}-service"
cluster = aws_ecs_cluster.this.id
task_definition = aws_ecs_task_definition.this[each.key].arn
scheduling_strategy = each.value.scheduling_strategy
desired_count = var.ecs_services[each.key].min_task
deployment_minimum_healthy_percent = 100
deployment_maximum_percent = 200
force_new_deployment = true
capacity_provider_strategy {
capacity_provider = local.spot_capacity_provider_name
base = 0
weight = 1
}
dynamic "ordered_placement_strategy" {
for_each = var.service_ordered_placement_strategies
content {
type = ordered_placement_strategy.value.type
field = ordered_placement_strategy.value.field
}
}
dynamic "placement_constraints" {
for_each = var.service_placement_constraints
content {
type = placement_constraints.value.type
expression = placement_constraints.value.expression
}
}
network_configuration {
security_groups = var.sg_ids
subnets = var.private_subnet_ids
}
load_balancer {
target_group_arn = lookup(var.target_group_arns, each.key)
container_name = each.key
container_port = lookup(var.ecs_services, each.key).container_port
}
service_registries {
registry_arn = aws_service_discovery_service.this[each.key].arn
}
deployment_circuit_breaker {
enable = true
rollback = true
}
depends_on = [aws_ecs_cluster.this, aws_ecs_capacity_provider.spot, var.target_group_arns]
lifecycle {
ignore_changes = [capacity_provider_strategy]
}
}