Terraform如何在更新lauch配置时强制AWS ASG创建新实例

时间:2017-03-14 16:15:47

标签: amazon-web-services amazon-ec2 terraform

当我更新AWS ASG的启动配置时,ASG会更新,但不会使用新的启动配置重新创建现有的运行实例。

如何告诉ASG重新创建实例?

这是我目前的terraform配置:

resource "aws_launch_configuration" "app-lc" {
  image_id             = "${var.ami}"
  instance_type        = "m4.large"
  security_groups      = ["${split(",", var.security_groups)}"]
  user_data            = "${file("user_data.sh")}"
  key_name             = "${var.key_name}"

  root_block_device {
    volume_type           = "standard"
    volume_size           = "50"
    delete_on_termination = "true"
  }

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_autoscaling_group" "app-asg" {
  name                      = "my-asg"
  max_size                  = "${var.asg_size}"
  min_size                  = "${var.asg_size}"
  desired_capacity          = "${var.asg_size}"
  launch_configuration      = "${aws_launch_configuration.app-lc.name}"
  health_check_type         = "EC2"
  health_check_grace_period = "600"
  vpc_zone_identifier       = ["${split(",", var.server_subnets)}"]
}

0 个答案:

没有答案