Hey Guys, I’m trying to bring up hosts inside my custom vpc using autoscaling and launch template. That doesn’t work, it works for 10 mins and outputs the message something like “The requested configuration is currently not supported.” I ensured that AMI and instance type is ok as i was able to make autoscaling and launch template working manually. But with terraform it fails. Please help. Here are my codes.
Creating AutoScaling Group
resource “aws_autoscaling_group” “my_asg” {
name = “my_asg”
target_group_arns = [aws_lb_target_group.my-target-group.id]
vpc_zone_identifier = [aws_subnet.custom_public1.id, aws_subnet.custom_public2.id]
min_size = 1
desired_capacity = 1
max_size = 3
default_cooldown = 180
health_check_type = “EC2”
termination_policies = [“OldestInstance”]
launch_template {
id = aws_launch_template.my_launch_temp.id
}
initial_lifecycle_hook {
name = “my_hook”
default_result = “CONTINUE”
heartbeat_timeout = 200
lifecycle_transition = “autoscaling:EC2_INSTANCE_LAUNCHING”
}
}
resource “aws_launch_template” “my_launch_temp” {
name = “my_launch_temp”
image_id = “ami-03c3a7e4263fd998c”
instance_type = “t2.micro”
ebs_optimized = true
vpc_security_group_ids = [aws_security_group.public_sg.id]
instance_initiated_shutdown_behavior = “terminate”
key_name = “kkk”
disable_api_termination = false
network_interfaces {
associate_public_ip_address = true
delete_on_termination = true
security_groups = [aws_security_group.public_sg.id]
}
iam_instance_profile {
name = “autoscaling”
}
monitoring {
enabled = true
}
tag_specifications {
resource_type = “instance”
tags = {
Name = "test"
}
}
}