【发布时间】:2021-04-21 20:52:48
【问题描述】:
当我更新与 aws_launch_template 关联的 AMI 时,Terraform 会按预期创建一个新版本的启动模板,并更新 aws_autoscaling_group 以指向新版本的启动模板。
但是,没有执行“滚动更新”以基于新 AMI 用新实例切换现有实例,我必须手动终止现有实例,然后 ASG 使用新 AMI 启动新实例。
我必须对我的配置进行哪些更改才能让 Terraform 执行滚动更新?
现有代码如下:
resource "aws_launch_template" "this" {
name_prefix = "my-launch-template-"
image_id = var.ami_id
instance_type = "t3.small"
key_name = "testing"
vpc_security_group_ids = [ aws_security_group.this.id ]
lifecycle {
create_before_destroy = true
}
}
resource "aws_autoscaling_group" "this" {
name_prefix = "my-asg-"
vpc_zone_identifier = var.subnet_ids
target_group_arns = var.target_group_arns
health_check_type = "ELB"
health_check_grace_period = 300
default_cooldown = 10
min_size = 4
max_size = 4
desired_capacity = 4
launch_template {
id = aws_launch_template.this.id
version = aws_launch_template.this.latest_version
}
lifecycle {
create_before_destroy = true
}
}
【问题讨论】:
标签: terraform terraform-provider-aws