-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstance-worker.tf
45 lines (35 loc) · 1.08 KB
/
instance-worker.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
resource "aws_launch_template" "template-worker" {
name_prefix = "locust-worker-template-"
image_id = var.aws_ami
instance_type = var.workers_instance_type
key_name = var.key_name
user_data = data.template_cloudinit_config.worker.rendered
network_interfaces {
associate_public_ip_address = true
subnet_id = aws_subnet.public_subnet.id
security_groups = [aws_security_group.master_sg.id]
delete_on_termination = true
}
tag_specifications {
resource_type = "instance"
tags = {
Name = "locust-worker"
}
}
}
resource "aws_autoscaling_group" "locust-workers-asg" {
min_size = var.workers_count
max_size = var.workers_count
desired_capacity = var.workers_count
launch_template {
id = aws_launch_template.template-worker.id
version = "$Latest"
}
vpc_zone_identifier = [aws_subnet.public_subnet.id]
health_check_type = "ELB"
health_check_grace_period = 300
termination_policies = ["OldestInstance"]
lifecycle {
create_before_destroy = true
}
}