-
Notifications
You must be signed in to change notification settings - Fork 6
/
ecs-service.tf
50 lines (42 loc) · 1.64 KB
/
ecs-service.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
resource "aws_ecs_service" "default" {
name = var.name
cluster = var.cluster_name
task_definition = aws_ecs_task_definition.default[0].arn
desired_count = var.desired_count
enable_execute_command = true
deployment_maximum_percent = try(var.deployment_maximum_percent, 100)
deployment_minimum_healthy_percent = try(var.deployment_minimum_healthy_percent, 0)
dynamic "placement_constraints" {
for_each = var.launch_type == "FARGATE" ? [] : var.placement_constraints
content {
expression = lookup(placement_constraints.value, "expression", null)
type = placement_constraints.value.type
}
}
dynamic "network_configuration" {
for_each = var.launch_type == "FARGATE" ? [var.subnets] : []
content {
subnets = var.subnets
security_groups = var.security_groups == "" ? null : var.security_groups
}
}
dynamic "ordered_placement_strategy" {
for_each = var.launch_type == "FARGATE" ? [] : var.ordered_placement_strategy
content {
field = lookup(ordered_placement_strategy.value, "field", null)
type = ordered_placement_strategy.value.type
}
}
dynamic "capacity_provider_strategy" {
for_each = try(var.without_capacity_provider, false) ? [] : ["1"]
content {
capacity_provider = var.launch_type == "FARGATE" ? (var.fargate_spot ? "FARGATE_SPOT" : "FARGATE") : "${var.cluster_name}-capacity-provider"
weight = 1
base = 0
}
}
lifecycle {
ignore_changes = [load_balancer, task_definition, desired_count, capacity_provider_strategy]
}
tags = var.tags
}