Skip to content

Commit 34e12b0

Browse files
authored
Merge pull request #42 from reactiveops/dk/s3-ep-routes
Add s3 endpoint routes for provided additional route tables
2 parents 620815b + fe569f0 commit 34e12b0

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ Considerations when enabling:
121121
* **ENABLING WILL DISRUPT CONNECTIONS** When initially enabling this any inflight S3 connections in the VPC [will be interrupted](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-endpoints-s3.html).
122122
* [DNS resolution must be enabled for the VPC].(https://docs.aws.amazon.com/vpc/latest/userguide/vpce-gateway.html#vpc-endpoints-limitations)
123123

124+
#### Additional Route Table Routes
125+
126+
By default when enabled all private subnet route tables will get a route for the S3 endpoint. You can pass additional route table ids for additional routes to be created. This is useful for route tables managed by Kops for example.
127+
124128
#### Endpoint S3 policy
125129

126130
Each endpoint has an associated IAM style policy attached. This module's default policy allows all access but can be overriden via TF variable `s3_vpc_endpoint_policy`. S3 bucket and IAM policies still apply. The endpoint policy is an additional limitation for connections through the endpoint.

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ variable "s3_vpc_endpoint_policy" {
164164
POLICY
165165
}
166166

167+
variable "s3_vpc_endpoint_route_table_ids" {
168+
description = "By default routes to the s3 endpoint are added for private subnet route tables. Pass additional route table ids that require routes."
169+
type = "list"
170+
default = []
171+
}
172+
167173
variable "internet_gateway_tags" {
168174
description = "Tags to apply to the internet gateway"
169175
default = {}

vpc-endpoint.tf

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#limitations under the License.
1414

1515
resource "aws_vpc_endpoint" "s3_endpoint" {
16-
count = "${var.enable_s3_vpc_endpoint ? 1 : 0}"
17-
vpc_id = "${aws_vpc.default.id}"
18-
service_name = "com.amazonaws.${var.aws_region}.s3"
19-
route_table_ids = ["${aws_route_table.private.*.id}"]
20-
policy = "${var.s3_vpc_endpoint_policy}"
16+
count = "${var.enable_s3_vpc_endpoint ? 1 : 0}"
17+
vpc_id = "${aws_vpc.default.id}"
18+
service_name = "com.amazonaws.${var.aws_region}.s3"
19+
route_table_ids = ["${concat(aws_route_table.private.*.id, var.s3_vpc_endpoint_route_table_ids)}"]
20+
policy = "${var.s3_vpc_endpoint_policy}"
2121
}

0 commit comments

Comments
 (0)