terraform - 当我添加到状态时,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 不会删除资源吗?
它会真正删除还是会意识到该州已经拥有它们?
解决方案
推荐阅读
- javascript - 在已定义的 JSON 文件中写入键的新值
- python - 情节甘特图
- python - Python3烧瓶接收文件并将其发送到另一个api
- python - 使用python将单列csv转换为多列csv?
- javascript - 如何在 HTML 画布中添加淡出效果
- apache-spark - Spark结构化流 - java.lang.OutOfMemoryError:Java堆空间
- python - 烧瓶路线模板
- html - 出现工具提示时增加滚动高度
- sql-server - 为指定的 IP 地址启用 SQL Server 远程连接
- php - 无法运行 Laravel Composer 更新 - RAM 和交换文件限制 - VPS