Skip to content

Commit

Permalink
fix: Fixed multiple VPC endpoint error for S3
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbabenko committed Feb 4, 2021
1 parent bc4c8a2 commit 6917378
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions vpc-endpoint.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
######################
# VPC Endpoint for S3
######################
data "aws_vpc_endpoint_service" "s3" {
count = "${var.create_vpc && var.enable_s3_endpoint ? 1 : 0}"
# Since 2.2.2021 there is an error:
# Error: multiple VPC Endpoint Services matched; use additional constraints to reduce matches to a single VPC Endpoint Service
# The solution is to not use aws_vpc_endpoint_service datasource, but use service_name explicitly in aws_vpc_endpoint.
#data "aws_vpc_endpoint_service" "s3" {
# count = "${var.create_vpc && var.enable_s3_endpoint ? 1 : 0}"
#
# service = "s3"
#}

service = "s3"
}
data "aws_region" "current" {}

resource "aws_vpc_endpoint" "s3" {
count = "${var.create_vpc && var.enable_s3_endpoint ? 1 : 0}"

vpc_id = "${local.vpc_id}"
service_name = "${data.aws_vpc_endpoint_service.s3.service_name}"
service_name = "com.amazonaws.${data.aws_region.current.name}.s3"

tags = "${local.vpce_tags}"
}
Expand Down

0 comments on commit 6917378

Please sign in to comment.