Skip to content

Commit 02ae641

Browse files
authored
feat: Add ability to create RDS endpoint to VPC (#499)
1 parent a51ad01 commit 02ae641

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Git-Codecommit, Transfer Server, Kinesis Streams, Kinesis Firehose, SageMaker(No
2626
CloudFormation, CodePipeline, Storage Gateway, AppMesh, Transfer, Service Catalog, AppStream,
2727
Athena, Rekognition, Elastic File System (EFS), Cloud Directory, Elastic Beanstalk (+ Health), Elastic Map Reduce(EMR),
2828
DataSync, EBS, SMS, Elastic Inference Runtime, QLDB Session, Step Functions, Access Analyzer, Auto Scaling Plans,
29-
Application Auto Scaling, Workspaces, ACM PCA.
29+
Application Auto Scaling, Workspaces, ACM PCA, RDS.
3030

3131
* [RDS DB Subnet Group](https://www.terraform.io/docs/providers/aws/r/db_subnet_group.html)
3232
* [ElastiCache Subnet Group](https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html)
@@ -242,7 +242,7 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
242242
| access\_analyzer\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for Access Analyzer endpoint. Only a single subnet within an AZ is supported. Ifomitted, private subnets will be used. | `list(string)` | `[]` | no |
243243
| acm\_pca\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for ACM PCA endpoint | `bool` | `false` | no |
244244
| acm\_pca\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for ACM PCA endpoint | `list` | `[]` | no |
245-
| acm\_pca\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for Codebuilt endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list` | `[]` | no |
245+
| acm\_pca\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for ACM PCA endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list` | `[]` | no |
246246
| amazon\_side\_asn | The Autonomous System Number (ASN) for the Amazon side of the gateway. By default the virtual private gateway is created with the current default Amazon ASN. | `string` | `"64512"` | no |
247247
| apigw\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for API GW endpoint | `bool` | `false` | no |
248248
| apigw\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for API GW endpoint | `list(string)` | `[]` | no |
@@ -435,6 +435,7 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
435435
| enable\_nat\_gateway | Should be true if you want to provision NAT Gateways for each of your private networks | `bool` | `false` | no |
436436
| enable\_public\_redshift | Controls if redshift should have public routing table | `bool` | `false` | no |
437437
| enable\_qldb\_session\_endpoint | Should be true if you want to provision an QLDB Session endpoint to the VPC | `bool` | `false` | no |
438+
| enable\_rds\_endpoint | Should be true if you want to provision an RDS endpoint to the VPC | `bool` | `false` | no |
438439
| enable\_rekognition\_endpoint | Should be true if you want to provision a Rekognition endpoint to the VPC | `bool` | `false` | no |
439440
| enable\_s3\_endpoint | Should be true if you want to provision an S3 endpoint to the VPC | `bool` | `false` | no |
440441
| enable\_sagemaker\_api\_endpoint | Should be true if you want to provision a SageMaker API endpoint to the VPC | `bool` | `false` | no |
@@ -536,6 +537,9 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
536537
| qldb\_session\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for QLDB Session endpoint | `bool` | `false` | no |
537538
| qldb\_session\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for QLDB Session endpoint | `list(string)` | `[]` | no |
538539
| qldb\_session\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for QLDB Session endpoint. Only a single subnet within an AZ is supported. Ifomitted, private subnets will be used. | `list(string)` | `[]` | no |
540+
| rds\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for RDS endpoint | `bool` | `false` | no |
541+
| rds\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for RDS endpoint | `list(string)` | `[]` | no |
542+
| rds\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for RDS endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list(string)` | `[]` | no |
539543
| redshift\_acl\_tags | Additional tags for the redshift subnets network ACL | `map(string)` | `{}` | no |
540544
| redshift\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for redshift subnets | `bool` | `false` | no |
541545
| redshift\_inbound\_acl\_rules | Redshift subnets inbound network ACL rules | `list(map(string))` | <pre>[<br> {<br> "cidr_block": "0.0.0.0/0",<br> "from_port": 0,<br> "protocol": "-1",<br> "rule_action": "allow",<br> "rule_number": 100,<br> "to_port": 0<br> }<br>]</pre> | no |

variables.tf

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,13 +1646,37 @@ variable "enable_acm_pca_endpoint" {
16461646
default = false
16471647
}
16481648

1649+
variable "enable_rds_endpoint" {
1650+
description = "Should be true if you want to provision an RDS endpoint to the VPC"
1651+
type = bool
1652+
default = false
1653+
}
1654+
1655+
variable "rds_endpoint_security_group_ids" {
1656+
description = "The ID of one or more security groups to associate with the network interface for RDS endpoint"
1657+
type = list(string)
1658+
default = []
1659+
}
1660+
1661+
variable "rds_endpoint_subnet_ids" {
1662+
description = "The ID of one or more subnets in which to create a network interface for RDS endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used."
1663+
type = list(string)
1664+
default = []
1665+
}
1666+
1667+
variable "rds_endpoint_private_dns_enabled" {
1668+
description = "Whether or not to associate a private hosted zone with the specified VPC for RDS endpoint"
1669+
type = bool
1670+
default = false
1671+
}
1672+
16491673
variable "acm_pca_endpoint_security_group_ids" {
16501674
description = "The ID of one or more security groups to associate with the network interface for ACM PCA endpoint"
16511675
default = []
16521676
}
16531677

16541678
variable "acm_pca_endpoint_subnet_ids" {
1655-
description = "The ID of one or more subnets in which to create a network interface for Codebuilt endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used."
1679+
description = "The ID of one or more subnets in which to create a network interface for ACM PCA endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used."
16561680
default = []
16571681
}
16581682

vpc-endpoints.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,3 +1348,26 @@ resource "aws_vpc_endpoint" "ses" {
13481348

13491349
tags = local.vpce_tags
13501350
}
1351+
1352+
######################
1353+
# VPC Endpoint for RDS
1354+
######################
1355+
data "aws_vpc_endpoint_service" "rds" {
1356+
count = var.create_vpc && var.enable_rds_endpoint ? 1 : 0
1357+
1358+
service = "rds"
1359+
}
1360+
1361+
resource "aws_vpc_endpoint" "rds" {
1362+
count = var.create_vpc && var.enable_rds_endpoint ? 1 : 0
1363+
1364+
vpc_id = local.vpc_id
1365+
service_name = data.aws_vpc_endpoint_service.rds[0].service_name
1366+
vpc_endpoint_type = "Interface"
1367+
1368+
security_group_ids = var.rds_endpoint_security_group_ids
1369+
subnet_ids = coalescelist(var.rds_endpoint_subnet_ids, aws_subnet.private.*.id)
1370+
private_dns_enabled = var.rds_endpoint_private_dns_enabled
1371+
1372+
tags = local.vpce_tags
1373+
}

0 commit comments

Comments
 (0)