[英]AWS VPC Endpoint for S3 with Terraform - Error: multiple VPC Endpoint Services matched
我在 Terraform (v0.11.14) 中使用aws_vpc_endpoint_service
在我的 AWS 賬戶上為 S3 創建 AWS VPC 終端節點,最近開始遇到以下錯誤: Error: multiple VPC Endpoint Services matched; use additional constraints to reduce matches to a single VPC Endpoint Service
Error: multiple VPC Endpoint Services matched; use additional constraints to reduce matches to a single VPC Endpoint Service
相同的代碼之前運行良好。 分辨率是多少?
我找到了解決方案。
問題的原因:
AWS Provider Version >= v3.10.0 的解決方案:
data "aws_vpc_endpoint_service" "s3" {
service = "s3"
service_type = "Gateway"
}
AWS Provider Version < v3.10.0 的解決方案:
如果您無法更新到提供程序的最新版本,作為臨時解決方法,您還可以使用 com.amazonaws.REGION.s3 作為下游配置中的端點值,而不是使用數據源。
data "aws_region" "current" {}
resource "aws_vpc_endpoint" "s3" {
vpc_id = "${local.vpc_id}"
service_name = "com.amazonaws.${data.aws_region.current.name}.s3"
}
就這些。
以前的參考代碼不再起作用:
data "aws_vpc_endpoint_service" "s3" {
service = "s3"
}
resource "aws_vpc_endpoint" "s3" {
vpc_id = "${local.vpc_id}"
service_name = "${data.aws_vpc_endpoint_service.s3.service_name}"
}
對於 aws provider < v3.10.0,可以使用aws_vpc_endpoint_service
中的filter
配置塊解決問題
data "aws_vpc_endpoint_service" "s3" {
service = "s3"
filter {
name = "service-type"
values = ["Gateway"]
}
}
resource "aws_vpc_endpoint" "s3" {
vpc_id = "${aws_vpc.vpc.id}"
service_name = "${data.aws_vpc_endpoint_service.s3.service_name}"
}
另請參閱 github 問題頁面https://github.com/hashicorp/terraform-provider-aws/issues/17417
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.