Terraform 在尝试扩展时销毁实例

Terraform destroy instances when trying to scale

我有 Terraform 的下一个实例,然后我在 instance/volume 上添加文件和安装软件。如果我重新部署 Terraform 计划以添加另一个实例,则该实例将被销毁并创建一个新实例。 如何才能不销毁实例?

#INSTANCE
resource "aws_instance" "DCOS-private-agent1" {
    ami = "${var.aws_centos_ami}"
    availability_zone = "eu-west-1b"
    instance_type = "t2.medium"
    key_name = "${var.aws_key_name}"
    security_groups = ["${aws_security_group.bastion.id}"]
    associate_public_ip_address = true
    private_ip = "10.0.0.14"
    source_dest_check = false
    subnet_id = "${aws_subnet.eu-west-1b-public.id}"

    tags {
            Name = "private-agent1"
        }
}
#VOLUME
data "aws_ebs_volume" "DCOS-private-agent1_ebs_volume" {
  most_recent = true
  filter {
    name   = "attachment.instance-id"
    values = ["${aws_instance.DCOS-private-agent1.id}"]
  }
}

已解决:

后续下一期:https://github.com/hashicorp/terraform/issues/6416

我的问题已解决,将 security_groups 替换为 vpc_security_group_ids