0.9.8
The relevant parts are here:
resource "aws_autoscaling_group" "web" {
name_prefix = "${var.application}--${data.template_file.environment_name.rendered}--"
launch_configuration = "${aws_launch_configuration.web.id}"
vpc_zone_identifier = ["${data.terraform_remote_state.vpc.all_subnet_ids[var.aws_region]}"]
min_size = "${var.asg_min_size}"
max_size = "${var.asg_max_size}"
load_balancers = ["${aws_elb.web.name}"]
health_check_type = "${var.health_check_type}"
metrics_granularity = "1Minute"
tag {
key = "Name"
value = "${var.application}--${data.template_file.environment_name.rendered}"
propagate_at_launch = true
}
tag {
key = "Terraform"
value = true
propagate_at_launch = true
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_launch_configuration" "web" {
name_prefix = "lc--${var.application}--${data.template_file.environment_name.rendered}--"
image_id = "${lookup(data.terraform_remote_state.amis.default_ami_ids, var.aws_region)}"
instance_type = "${var.instance_type}"
iam_instance_profile = "${var.iam_instance_profile_id}"
security_groups = ["${aws_security_group.instance.id}"]
associate_public_ip_address = false
user_data = "${data.template_file.init_instance.rendered}"
key_name = "${lookup(data.terraform_remote_state.ssh_keys.key_names, data.template_file.environment_name.rendered)}"
connection = {
user = "ubuntu"
}
lifecycle {
create_before_destroy = true
}
}
Instances should be replaced after launch configuration change.
The instances are not replaced.
I believe this could be solved using autoscaling lifecycle hooks, but I couldn't find out how.
Any updates here?
Is this feature already available?
You can set the name_prefix
of your auto-scaling group to include the generated name of your launch_configuration
which will force a new auto-scaling group to be created when the launch configuration changes (as its name will change since you are using name_prefix
there as well).
resource "aws_autoscaling_group" "web" {
name_prefix = "${aws_launch_configuration.web.name}--"
There's been some discussion around this in the past, such as #1452 and the Google Groups thread linked there.
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.
If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
You can set the
name_prefix
of your auto-scaling group to include the generated name of yourlaunch_configuration
which will force a new auto-scaling group to be created when the launch configuration changes (as its name will change since you are usingname_prefix
there as well).