设置简单的Windows EC2实例要破坏VPC和资源

时间:2019-06-18 07:07:10

标签: terraform terraform-provider-aws

我已经精简了代码并重现了我的问题...我创建了一个只有一个子网的简单VPC。

在Windows上使用Terraform v0.12.1

创建VPC之后,我只是尝试部署EC2实例(Server 2019 Core)...为此实例运行``地形计划''时,它想要创建EC2实例并销毁一个子网并VPC

只是好奇是否有人遇到过这个问题,或者对到底是什么造成破坏的原因有任何想法?

将计划简化为几乎没有... 操作顺序: 1. Terraform申请创建VPC 2.记下子网ID并修改计划以供EC2实例使用 3.针对EC2实例的计划的Terraform计划

# VPC plan
provider "aws" {
    region = "ca-central-1"
    profile = "blablabla"
}

resource "aws_vpc" "dev" {
    #cidr_block = "10.0.0.0/16"
    cidr_block = "10.0.2.0/24"
    enable_dns_hostnames = true
}

resource "aws_subnet" "private-subnet" {
    vpc_id = "${aws_vpc.dev.id}"
    cidr_block = "10.0.2.0/24"
}
# EC2 plan
provider "aws" {
 profile = "blablabla"
 region     = "ca-central-1"
}

data "aws_ami" "latest-win2019-core" {
most_recent = true
owners = ["amazon"]

  filter {
    name = "name"
    values = ["Windows_Server-2019-English-Core-Base*"]
  }
}

resource "aws_instance" "win-2019-core" {
  ami           = "${data.aws_ami.latest-win2019-core.id}"
  instance_type = "t2.micro"
  subnet_id = "subnet-04801d62b22ad8dc0"
}

计划输出:

  # aws_subnet.private-subnet will be destroyed
  - resource "aws_subnet" "private-subnet" {
      - arn                             = "arn:aws:ec2:ca-central-1:3...." -> null
      - assign_ipv6_address_on_creation = false -> null
      - availability_zone               = "ca-central-1a" -> null
      - availability_zone_id            = "cac1-az1" -> null
      - cidr_block                      = "10.0.2.0/24" -> null
      - id                              = "subnet-04801d62b22ad8dc0" -> null
      - map_public_ip_on_launch         = false -> null
      - owner_id                        = "366481676110" -> null
      - tags                            = {} -> null
      - vpc_id                          = "vpc-0fd0f22b95456364d" -> null
    }

  # aws_vpc.dev will be destroyed
  - resource "aws_vpc" "dev" {
      - arn                              = "arn:aws:ec2:ca-central-1:3...." -> null
      - assign_generated_ipv6_cidr_block = false -> null
      - cidr_block                       = "10.0.2.0/24" -> null
      - default_network_acl_id           = "acl-0edb8e4b47405fa20" -> null
      - default_route_table_id           = "rtb-046e1eeb314d510b0" -> null
      - default_security_group_id        = "sg-031e10e2228957ead" -> null
      - dhcp_options_id                  = "dopt-1ae43972" -> null
      - enable_dns_hostnames             = true -> null
      - enable_dns_support               = true -> null
      - id                               = "vpc-0fd0f22b95456364d" -> null
      - instance_tenancy                 = "default" -> null
      - main_route_table_id              = "rtb-046e1eeb314d510b0" -> null
      - owner_id                         = "366481676110" -> null
      - tags                             = {} -> null
    }

Plan: 1 to add, 0 to change, 2 to destroy.

0 个答案:

没有答案