-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASG.tf
31 lines (26 loc) · 1.11 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
######################################################################################
# AUTO SCALING GROUP CONFIGURATION
######################################################################################
resource "aws_launch_configuration" "demo_instance_auto" {
name = "demo_instance_auto"
image_id = var.image_id
instance_type = var.instance_type
key_name = var.keypair
security_groups = [aws_security_group.ec2_sg.id]
user_data = base64encode(file("apache.sh"))
}
resource "aws_autoscaling_group" "asg" {
max_size = 2
desired_capacity = 1
min_size = 0
health_check_grace_period = 300
force_delete = true
health_check_type = "ELB"
target_group_arns = [aws_lb_target_group.alb_tg.arn]
depends_on = [aws_launch_configuration.demo_instance_auto]
launch_configuration = aws_launch_configuration.demo_instance_auto.id
vpc_zone_identifier = [aws_subnet.private_subnet_1a.id, aws_subnet.private_subnet_1b.id]
timeouts {
delete = "15m"
}
}