Here you usually need to use the Terraform Lifecycle Management to force it to create new resources before destroying the old ones.
:
resource "aws_launch_configuration" "as_conf" {
name_prefix = "terraform-lc-example-"
image_id = "${var.ami_id}"
instance_type = "t1.micro"
lifecycle {
create_before_destroy = true
}
}
resource "aws_autoscaling_group" "bar" {
name = "terraform-asg-example-${aws_launch_configuration.as_conf.name}"
launch_configuration = "${aws_launch_configuration.as_conf.name}"
lifecycle {
create_before_destroy = true
}
}
, ami_id, AMI Terraform, , , . , LC, ASG, ASG .
create_before_destroy Terraform LC ASG , ASG ( ), ASG, LC.
ASG . , 2 ASG, 2 , , 2 . , ELB ASG, ELB, 4 , 2.