如何使用数据“ AWS_VPC_ENDPOINT”检索多个端点。资源?
错误:“匹配的多个VPC端点”
我正在使用一个数据“ AWS_VPC_ENDPOINT”来根据VPC ID检索多个端点ID。如何检索这些终点以在另一个资源中引用它们?还是可以从此数据资源中检索多端点。有什么建议吗?或建议将不胜感激。这是代码段。 Count.Index已在资源“ AWS_ROUTE”中正确考虑到我的重点是检索多个端点以添加到AWS_ROUTE中。
data "aws_vpc_endpoint" "firewall-endpoints" {
vpc_id = aws_vpc.vpc.id
filter {
name = "tag:Example"
values = [true]
}
}
resource "aws_route" "example" {
count = var.number_azs
route_table_id = aws_route_table.example[count.index].id
destination_cidr_block = var.tgw_aws_route[0]
vpc_endpoint_id = data.aws_vpc_endpoint_service.firewall-endpoints.id
}
Error: “multiple VPC Endpoints matched”
I am using a data “aws_vpc_endpoint” to retrieve multiple endpoint IDs based on the vpc ID. How can I retrieve these endpoints to reference them in another resource? Or is it possible to retrieve multiple endpoint from this data resource. Any suggestions? Or advice would be much appreciated. Here is the code snippet. The count.index has been accounted for correctly already in resource "aws_route" now I am focused on retrieving multiple endpoints to add to the aws_route.
data "aws_vpc_endpoint" "firewall-endpoints" {
vpc_id = aws_vpc.vpc.id
filter {
name = "tag:Example"
values = [true]
}
}
resource "aws_route" "example" {
count = var.number_azs
route_table_id = aws_route_table.example[count.index].id
destination_cidr_block = var.tgw_aws_route[0]
vpc_endpoint_id = data.aws_vpc_endpoint_service.firewall-endpoints.id
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想将VPC端点用于多个服务,则需要为每个服务创建一个数据源。可以用
for_each
来完成此操作。更新:我不确定如何设置端点,但是您需要找到一种独特的方式来引用它们。在这里使用
for_each
的一个示例可能是这样的:然后使用端点,您可以将其称为eg
data.aws_vpc_endpoint.services.services [“ s3”]。id
。而且,如果您想循环循环它们,则可以再次参考local.services
字典。The documentation is pretty explicit:
If you want to use VPC endpoints for multiple services, you'll need to create a data source for each one. This could be done concisely with
for_each
.Update: I'm not sure how your endpoints are set up, but you need to find a unique way to refer to them. An example of using
for_each
here could look like this:To then use the endpoint, you can refer to it as e.g.
data.aws_vpc_endpoint.services["s3"].id
. And if you want to loop over them, you can again refer to thelocal.services
dictionary.您可以尝试
您可以添加,但我不确定VPC端点的类型是什么。
You can try aws_resourcegroupstaggingapi_resources to return multiple resources that have specific tags:
you can add resource_type_filters but I'm not sure what is the type for VPC endpoints.
作为格式作为答案的答案很烂,当将其作为评论以答案:
Posting as an answer as formatting sucks when posted as comment to an answer: