[英]terraform aws - how to add default route to vpc default route table?
[英]How can I add route to VPC Gateway endpoint for AWS network firewall using terraform
我正在使用 Terraform 部署 AWS 網絡防火牆並出現以下錯誤。
Error: error creating route: InvalidParameterValue: route table rtb-060e56b4e1a9ea33c and interface eni-09505345a50ed2786 belong to different networks
status code: 400, request id: b28dae26-ddec-42c0-b0d1-4443b224e55f
on main.tf line 252, in resource "aws_route_table" "tgw-inspection-RT":
252: resource "aws_route_table" "tgw-inspection-RT" {
下面是一段代碼,我試圖在其中添加一條路由,以便 TGW 將所有流量發送到 AWS 網絡防火牆 VPC 端點。
resource "aws_route_table" "tgw-inspection-RT" {
provider = aws.region-master
vpc_id = aws_vpc.inspection-vpc.id
route {
cidr_block = "0.0.0.0/0"
network_interface_id = data.aws_network_interface.firewall-int.id
}
tags = {
Name = "tgw-inspection-RT"
}
}
我嘗試使用“vpc_endpoint_id = aws_networkfirewall_firewall.terraform-anf.id”添加,但仍然出現錯誤。
我嘗試了其他方法以及以下文檔中提到的方法,但仍然出現錯誤。 https://github.com/giuseppeborgese/terraform-aws-network-firewall-poc/blob/main/vpc.tf
任何幫助將不勝感激 !
不記得我在哪里看到的,但看起來像這種性質的東西: data.aws_networkfirewall_firewall.network_firewall.firewall_status[0].sync_states
我用這個讓它工作了
resource "aws_route_table" "rt_inbound" {
count = 3
vpc_id = aws_vpc.vpc.id
route {
cidr_block = "0.0.0.0/0"
vpc_endpoint_id = element(flatten(aws_networkfirewall_firewall.network_firewall.firewall_status[0].sync_states[*].attachment[*].endpoint_id), count.index)
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.