当我添加到状态时,Terraform希望销毁并创建新资源

时间:2019-05-01 17:50:01

标签: terraform

我要添加到没有更改的现有状态。我要添加另一个子网,当我添加它时,它还将创建一个NATGW和一些路由。 TF想要删除我现有的NATGW。

###################
# NAT Gateway
###################
resource "aws_nat_gateway" "nat_gw" {
  count         = "${length(var.public_subnets)}"
  allocation_id = "${element(var.eip_allocation_ids, count.index)}"
  subnet_id     = "${element(aws_subnet.public.*.id, count.index)}"
  tags          = "${merge(var.tags, var.public_id_subnet_tags, map("Name", format("%s-nat-gateway-%s", var.name, element(var.azs, count.index))))}"
}
-/+ module.networking.aws_nat_gateway.nat_gw[0] (new resource required)
      id:                                          "nat-023d47bfdddfc6389" => <computed> (forces new resource)
      allocation_id:                               "eipalloc-ca1c41f5" => "eipalloc-ca1c41f5"
      network_interface_id:                        "eni-fc7d66e0" => <computed>
      private_ip:                                  "172.51.1.127" => <computed>
      public_ip:                                   "52.0.0.x" => <computed>
      subnet_id:                                   "subnet-e56960bc" => "${element(aws_subnet.public.*.id, count.index)}" (forces new resource)
      tags.%:                                      "1" => "1"
      tags.Name:                                   "dl-vpce0-nat-gateway-us-east-1a" => "us-east-1a"

-/+ module.networking.aws_nat_gateway.nat_gw[1] (new resource required)
      id:                                          "nat-09e0d9274a63e4d9d" => <computed> (forces new resource)
      allocation_id:                               "eipalloc-fbefbdc4" => "eipalloc-fbefbdc4"
      network_interface_id:                        "eni-d70af6ce" => <computed>
      private_ip:                                  "172.51.20.35" => <computed>
      public_ip:                                   "52.0.0.x" => <computed>
      subnet_id:                                   "subnet-69e5121f" => "${element(aws_subnet.public.*.id, count.index)}" (forces new resource)
      tags.%:                                      "1" => "1"
      tags.Name:                                   "dl-vpce0-nat-gateway-us-east-1d" => "us-east-1d"

-/+ module.networking.aws_nat_gateway.nat_gw[2] (new resource required)
      id:                                          "nat-0a7622fe5416aa1ad" => <computed> (forces new resource)
      allocation_id:                               "eipalloc-36f6bd09" => "eipalloc-36f6bd09"
      network_interface_id:                        "eni-757c737a" => <computed>
      private_ip:                                  "172.51.51.224" => <computed>
      public_ip:                                   "52.0.0.x" => <computed>
      subnet_id:                                   "subnet-9dc16ca0" => "${element(aws_subnet.public.*.id, count.index)}" (forces new resource)
      tags.%:                                      "1" => "1"
      tags.Name:                                   "dl-vpce0-nat-gateway-us-east-1e" => "us-east-1e"

  + module.networking.aws_nat_gateway.nat_gw[3]
      id:                                          <computed>
      allocation_id:                               "eipalloc-ca1c41f5"
      network_interface_id:                        <computed>
      private_ip:                                  <computed>
      public_ip:                                   <computed>
      subnet_id:                                   "${element(aws_subnet.public.*.id, count.index)}"
      tags.%:                                      "1"
      tags.Name:                                   "dl-vpce0-nat-gateway-us-east-1c"

有没有一种使用方法:

"${element(aws_subnet.public.*.id, count.index)}"

如果我添加更多子网,没有TF删除资源吗?

它实际上会删除还是会意识到状态已经存在?

0 个答案:

没有答案