找不到Terraform AWS VCPe路由创建端点



当我创建到端点的路由时,我得到以下错误:

InvalidVpcEndpointId.NotFound: The vpcEndpoint ID 'vpce-044e0beXXXXXXXX' does not exist.

但是在输出中(以及在控制台上),我可以看到端点被创建:

module.sec.aws_vpc_endpoint.s3[0]: Creation complete after 6s [id=vpce-044e0beXXXXXXXXX]

下面是我创建路由的方法:

resource "aws_route" "s3_route" {
count = length(var.s3_routes)
route_table_id         = aws_route_table.main.id
destination_cidr_block = var.s3_routes[count.index]
vpc_endpoint_id        = var.s3_endpoint_ID[0]
}

这个模块是调用它的一个例子:

module "sec-route-NATGW-ifw-a" {
source = "./route"
depends_on = [module.i-dmz, module.t-dmz, module.cde, module.tgw-core, module.tgw-ifw]
vpc_id = module.sec.vpc_id
subnet_association = [for s in range(0, length(module.sec.natgw_subnet_IDs)) : module.sec.natgw_subnet_IDs[s] if module.sec.natgw_subnet_AZs[s] == "${local.region}a"]
s3_endpoint_ID = module.sec.s3_endpoint_ID
s3_routes = local.s3_ips      
}

下面是ID的输出:

output "s3_endpoint_ID" {
value = aws_vpc_endpoint.s3[*].id
description = "ID for S3 Endpoint"
}

和创建端点的资源:

resource "aws_vpc_endpoint" "s3" {
count = var.s3_servicename == "" ? 0 : 1
vpc_id       = aws_vpc.SEC.id
service_name = var.s3_servicename
}

仅供参考,VPCE ID已从脚本更改。

问题是我的路由资源的配置,我用以下内容替换了它:

resource "aws_vpc_endpoint_route_table_association" "s3" {
count = length(var.s3_endpoint_ID) == 0 ? 0 : 1
route_table_id = aws_route_table.main.id
vpc_endpoint_id = tostring(var.s3_endpoint_ID[0])
} 

我不认为tostring()是需要的,我稍微改变了count的工作方式,但是添加destination_cidr_block参数是问题所在。

最新更新