Skip to content

Commit 06fccd6

Browse files
authored
fix: Specify an endpoint type for S3 VPC endpoint (#573)
1 parent a78cee9 commit 06fccd6

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ These types of resources are supported:
1919
* [VPC Flow Log](https://www.terraform.io/docs/providers/aws/r/flow_log.html)
2020
* [VPC Endpoint](https://www.terraform.io/docs/providers/aws/r/vpc_endpoint.html):
2121
* Gateway: S3, DynamoDB
22-
* Interface: EC2, SSM, EC2 Messages, SSM Messages, SQS, ECR API, ECR DKR, API Gateway, KMS,
22+
* Interface: S3, EC2, SSM, EC2 Messages, SSM Messages, SQS, ECR API, ECR DKR, API Gateway, KMS,
2323
ECS, ECS Agent, ECS Telemetry, SES, SNS, STS, Glue, CloudWatch(Monitoring, Logs, Events),
2424
Elastic Load Balancing, CloudTrail, Secrets Manager, Config, Codeartifact(API, Repositories), CodeBuild, CodeCommit,
2525
Git-Codecommit, Textract, Transfer Server, Kinesis Streams, Kinesis Firehose, SageMaker(Notebook, Runtime, API),
@@ -353,6 +353,7 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
353353
| dms\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for DMS endpoint | `bool` | `false` | no |
354354
| dms\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for DMS endpoint | `list(string)` | `[]` | no |
355355
| dms\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for DMS endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list(string)` | `[]` | no |
356+
| dynamodb\_endpoint\_type | DynamoDB VPC endpoint type | `string` | `"Gateway"` | no |
356357
| ebs\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for EBS endpoint | `bool` | `false` | no |
357358
| ebs\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for EBS endpoint | `list(string)` | `[]` | no |
358359
| ebs\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for EBS endpoint. Only a single subnet within an AZ is supported. Ifomitted, private subnets will be used. | `list(string)` | `[]` | no |
@@ -589,6 +590,7 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
589590
| rekognition\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for Rekognition endpoint | `list(string)` | `[]` | no |
590591
| rekognition\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for Rekognition endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list(string)` | `[]` | no |
591592
| reuse\_nat\_ips | Should be true if you don't want EIPs to be created for your NAT Gateways and will instead pass them in via the 'external\_nat\_ip\_ids' variable | `bool` | `false` | no |
593+
| s3\_endpoint\_type | S3 VPC endpoint type | `string` | `"Gateway"` | no |
592594
| sagemaker\_api\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for SageMaker API endpoint | `bool` | `false` | no |
593595
| sagemaker\_api\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for SageMaker API endpoint | `list(string)` | `[]` | no |
594596
| sagemaker\_api\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for SageMaker API endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list(string)` | `[]` | no |

examples/simple-vpc/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ module "vpc" {
1818
enable_nat_gateway = true
1919
single_nat_gateway = true
2020

21+
# s3_endpoint_type = "Interface"
22+
23+
enable_s3_endpoint = true
24+
enable_dynamodb_endpoint = true
25+
2126
public_subnet_tags = {
2227
Name = "overridden-name-public"
2328
}

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,24 @@ variable "enable_dynamodb_endpoint" {
316316
default = false
317317
}
318318

319+
variable "dynamodb_endpoint_type" {
320+
description = "DynamoDB VPC endpoint type"
321+
type = string
322+
default = "Gateway"
323+
}
324+
319325
variable "enable_s3_endpoint" {
320326
description = "Should be true if you want to provision an S3 endpoint to the VPC"
321327
type = bool
322328
default = false
323329
}
324330

331+
variable "s3_endpoint_type" {
332+
description = "S3 VPC endpoint type"
333+
type = string
334+
default = "Gateway"
335+
}
336+
325337
variable "enable_codeartifact_api_endpoint" {
326338
description = "Should be true if you want to provision an Codeartifact API endpoint to the VPC"
327339
type = bool

vpc-endpoints.tf

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
data "aws_vpc_endpoint_service" "s3" {
55
count = var.create_vpc && var.enable_s3_endpoint ? 1 : 0
66

7-
service = "s3"
7+
service_type = var.s3_endpoint_type
8+
service = "s3"
89
}
910

1011
resource "aws_vpc_endpoint" "s3" {
1112
count = var.create_vpc && var.enable_s3_endpoint ? 1 : 0
1213

13-
vpc_id = local.vpc_id
14-
service_name = data.aws_vpc_endpoint_service.s3[0].service_name
15-
tags = local.vpce_tags
14+
vpc_id = local.vpc_id
15+
service_name = data.aws_vpc_endpoint_service.s3[0].service_name
16+
vpc_endpoint_type = var.s3_endpoint_type
17+
18+
tags = local.vpce_tags
1619
}
1720

1821
resource "aws_vpc_endpoint_route_table_association" "private_s3" {
@@ -42,15 +45,18 @@ resource "aws_vpc_endpoint_route_table_association" "public_s3" {
4245
data "aws_vpc_endpoint_service" "dynamodb" {
4346
count = var.create_vpc && var.enable_dynamodb_endpoint ? 1 : 0
4447

45-
service = "dynamodb"
48+
service_type = var.dynamodb_endpoint_type
49+
service = "dynamodb"
4650
}
4751

4852
resource "aws_vpc_endpoint" "dynamodb" {
4953
count = var.create_vpc && var.enable_dynamodb_endpoint ? 1 : 0
5054

51-
vpc_id = local.vpc_id
52-
service_name = data.aws_vpc_endpoint_service.dynamodb[0].service_name
53-
tags = local.vpce_tags
55+
vpc_id = local.vpc_id
56+
vpc_endpoint_type = var.dynamodb_endpoint_type
57+
service_name = data.aws_vpc_endpoint_service.dynamodb[0].service_name
58+
59+
tags = local.vpce_tags
5460
}
5561

5662
resource "aws_vpc_endpoint_route_table_association" "private_dynamodb" {

0 commit comments

Comments
 (0)