-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathasg.tf
66 lines (53 loc) · 1.64 KB
/
asg.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
63
64
65
66
resource "aws_autoscaling_group" "ecs" {
name = "ecs-${var.name}"
mixed_instances_policy {
launch_template {
launch_template_specification {
launch_template_id = aws_launch_template.ecs.id
version = "$Latest"
}
override {
instance_type = var.instance_type_1
}
override {
instance_type = var.instance_type_2
}
override {
instance_type = var.instance_type_3
}
}
instances_distribution {
spot_instance_pools = 3
on_demand_base_capacity = var.on_demand_base_capacity
on_demand_percentage_above_base_capacity = var.on_demand_percentage
}
}
vpc_zone_identifier = var.private_subnet_ids
min_size = 1
max_size = 1
protect_from_scale_in = var.asg_protect_from_scale_in
tag {
key = "Name"
value = "ecs-node-${var.name}"
propagate_at_launch = true
}
target_group_arns = var.target_group_arns
health_check_grace_period = var.autoscaling_health_check_grace_period
default_cooldown = var.autoscaling_default_cooldown
lifecycle {
create_before_destroy = true
}
}
resource "aws_ecs_capacity_provider" "ecs_capacity_provider" {
name = "${var.name}-capacity-provider"
auto_scaling_group_provider {
auto_scaling_group_arn = aws_autoscaling_group.ecs.arn
managed_termination_protection = "DISABLED"
managed_scaling {
maximum_scaling_step_size = 10
minimum_scaling_step_size = 1
status = "ENABLED"
target_capacity = var.asg_target_capacity
}
}
}