-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.tf
44 lines (37 loc) · 1.22 KB
/
nodes.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
resource "aws_launch_template" "ecs_ec2" {
name_prefix = "${local.identifier}-ecs-ec2"
image_id = data.aws_ssm_parameter.ecs_node_ami.value
instance_type = var.node_instance_type
vpc_security_group_ids = [aws_security_group.ecs_node_sg.id]
iam_instance_profile { arn = aws_iam_instance_profile.ecs_node.arn }
monitoring { enabled = true }
metadata_options { http_tokens = "required" }
user_data = base64encode(<<-EOF
#!/bin/bash
echo ECS_CLUSTER=${aws_ecs_cluster.main.name} >> /etc/ecs/ecs.config;
EOF
)
}
resource "aws_autoscaling_group" "ecs" {
name_prefix = "${local.identifier}-ecs-asg"
vpc_zone_identifier = local.subnet_ids
min_size = 2
max_size = 8
health_check_grace_period = 0
health_check_type = "EC2"
protect_from_scale_in = false
launch_template {
id = aws_launch_template.ecs_ec2.id
version = "$Latest"
}
tag {
key = "Name"
value = "${local.identifier}-ecs-cluster"
propagate_at_launch = true
}
tag {
key = "AmazonECSManaged"
value = "true"
propagate_at_launch = true
}
}