Skip to content

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

main.tf

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,22 @@ resource "aws_nat_gateway" "natgw" {
9999
depends_on = ["aws_internet_gateway.mod"]
100100
}
101101

102-
data "aws_vpc_endpoint_service" "s3" {
103-
service = "s3"
104-
}
102+
# Since 2.2.2021 there is an error:
103+
# Error: multiple VPC Endpoint Services matched; use additional constraints to reduce matches to a single VPC Endpoint Service
104+
# The solution is to not use aws_vpc_endpoint_service datasource, but use service_name explicitly in aws_vpc_endpoint.
105+
#data "aws_vpc_endpoint_service" "s3" {
106+
# count = "${var.enable_s3_endpoint ? 1 : 0}"
107+
#
108+
# service = "s3"
109+
#}
110+
111+
data "aws_region" "current" {}
105112

106113
resource "aws_vpc_endpoint" "ep" {
107-
vpc_id = "${aws_vpc.mod.id}"
108-
service_name = "${data.aws_vpc_endpoint_service.s3.service_name}"
109114
count = "${var.enable_s3_endpoint}"
115+
116+
vpc_id = "${aws_vpc.mod.id}"
117+
service_name = "com.amazonaws.${data.aws_region.current.name}.s3"
110118
}
111119

112120
resource "aws_vpc_endpoint_route_table_association" "private_s3" {

0 commit comments

Comments
 (0)