Terraform在尝试扩展时销毁实例

时间:2017-05-16 07:09:38

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

我有Terraform的下一个实例,然后我在实例/卷上添加文件并安装软件。如果我重新部署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}"]
  }
}

1 个答案:

答案 0 :(得分:0)

解决:

关注下一期:https://github.com/hashicorp/terraform/issues/6416

我的问题已经解决,用security_groups替换vpc_security_group_ids