VPC对等互联一直被Terraform所取代



我正在尝试在两个不同帐户的两个VPC之间创建VPC对等。一个是我管理的,另一个是别人管理的,我没有权限。我正在使用Terraform脚本的下一个片段。

resource "aws_vpc_peering_connection" "a" {
peer_owner_id = var.a.aws_account_id
peer_vpc_id   = var.a.vpc_id
vpc_id        = aws_vpc.main.id
peer_region   = "eu-west-1"
requester {
allow_remote_vpc_dns_resolution = false
}
}

接下来,它将由管理该帐户的人员手动接受。问题是是否接受对等连接Terraform想要replace对等连接:

# module.vpc.aws_vpc_peering_connection.a is tainted, so must be replaced
-/+ resource "aws_vpc_peering_connection" "a" {
~ accept_status = "active" -> (known after apply)
~ id            = "pcx-00000000000000000" -> (known after apply)
# (5 unchanged attributes hidden)
+ accepter {
+ allow_classic_link_to_remote_vpc = (known after apply)
+ allow_remote_vpc_dns_resolution  = (known after apply)
+ allow_vpc_to_remote_classic_link = (known after apply)
}
# (1 unchanged block hidden)
}

我已经尝试使用lifecycle

来阻止替换
lifecycle {
ignore_changes = all
}

但它没有帮助…

尝试不污染资源,例如

terraform untaint aws_vpc_peering_connection.a

通过使用aws_vpc_peering_connection_options资源而不是在aws_vpc_peering_connection请求程序中指定选项,当Terraform注意到allow_remote_vpc_dns_resolution选项已经更改时,我能够避免重新创建连接本身。

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_peering_connection_options

在对等连接被另一方接受之前设置该选项仍然会失败,但是一旦你在另一方账户上接受了连接,只有选项会被污染,而不是整个连接。

最新更新