Use the AWS VPC Endpoints sub-module
masterThe vpc-endpoints sub-module allows you to create both Interface and Gateway VPC endpoints on AWS. You define endpoints using an endpoints map where each key represents a service and the value contains the specific configuration for that service type.
To use this module, provide the vpc_id and a map of endpoints. You can configure different settings for Interface endpoints (using subnet_ids and subnet_configurations) and Gateway endpoints (using service_type = "Gateway" and route_table_ids).
module "endpoints" {
source = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"
vpc_id = "vpc-12345678"
security_group_ids = ["sg-12345678"]
endpoints = {
s3 = {
# interface endpoint
service = "s3"
tags = { Name = "s3-vpc-endpoint" }
},
dynamodb = {
# gateway endpoint
service = "dynamodb"
service_type = "Gateway"
route_table_ids = ["rt-12322456", "rt-43433343", "rt-11223344"]
tags = { Name = "dynamodb-vpc-endpoint" }
},
sns = {
service = "sns"
subnet_ids = ["subnet-12345678", "subnet-87654321"]
subnet_configurations = [
{
ipv4 = "10.8.34.10"
subnet_id = "subnet-12345678"
},
{
ipv4 = "10.8.35.10"
subnet_id = "subnet-87654321"
}
]
tags = { Name = "sns-vpc-endpoint" }
},
sqs = {
service = "sqs"
private_dns_enabled = true
security_group_ids = ["sg-987654321"]
subnet_ids = ["subnet-12345678", "subnet-87654321"]
tags = { Name = "sqs-vpc-endpoint" }
},
}
tags = {
Owner = "user"
Environment = "dev"
}
}