Skip to content

Commit 9e5a88b

Browse files
authored
feat(vpc): add s3 gateway endpoint (#165)
<!-- ~ Copyright 2023 StreamNative, Inc. ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <!-- ### Contribution Checklist - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review. - Each pull request should address only one issue, not mix up code from multiple issues. - Each commit in the pull request has a meaningful commit message - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below. **(The sections below can be removed for hotfixes of typos)** --> ### Motivation Creating S3 Gateway Endpoint when creating a new VPC ### Modifications - Add a new `aws_vpc_endpoint` ### Verifying this change - [x] Make sure that the change passes the CI checks. *(Please pick either of the following options)* This change is a trivial rework / code cleanup without any test coverage. *(or)* This change is already covered by existing tests, such as *(please describe tests)*. *(or)* This change added tests and can be verified as follows: *(example:)* - *Added integration tests for end-to-end deployment with large payloads (10MB)* - *Extended integration test for recovery after broker failure* ### Documentation - [x] `doc` --------- Signed-off-by: Max Xu <[email protected]>
1 parent 9a19def commit 9e5a88b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

modules/vpc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ No modules.
6363
| [aws_subnet.private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
6464
| [aws_subnet.public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
6565
| [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource |
66+
| [aws_vpc_endpoint.s3_gateway_endpoint](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_endpoint) | resource |
6667
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
6768

6869
## Inputs

modules/vpc/main.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,31 @@ resource "aws_route_table_association" "private_assoc" {
143143
subnet_id = aws_subnet.private[count.index].id
144144
route_table_id = aws_route_table.private_route_table[count.index].id
145145
}
146+
147+
resource "aws_vpc_endpoint" "s3_gateway_endpoint" {
148+
count = var.disable_nat_gateway ? 0 : 1
149+
150+
vpc_id = aws_vpc.vpc.id
151+
service_name = format("com.amazonaws.%s.s3", var.region)
152+
route_table_ids = aws_route_table.private_route_table[*].id
153+
vpc_endpoint_type = "Gateway"
154+
155+
policy = <<POLICY
156+
{
157+
"Version": "2008-10-17",
158+
"Statement": [
159+
{
160+
"Effect": "Allow",
161+
"Principal": "*",
162+
"Action": "*",
163+
"Resource": "*"
164+
}
165+
]
166+
}
167+
POLICY
168+
169+
tags = {
170+
Name = "${var.vpc_name}-s3-gateway-endpoint"
171+
Vendor = "StreamNative"
172+
}
173+
}

0 commit comments

Comments
 (0)