Skip to content

Commit ec49d43

Browse files
DrFaust92antonbabenko
authored andcommitted
Add Elastic File System & Cloud Directory VPC Endpoints (#355)
1 parent 7a99e44 commit ec49d43

File tree

4 files changed

+141
-1
lines changed

4 files changed

+141
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ECS, ECS Agent, ECS Telemetry, SNS, STS, Glue, CloudWatch(Monitoring, Logs, Even
2121
Elastic Load Balancing, CloudTrail, Secrets Manager, Config, CodeBuild, CodeCommit,
2222
Git-Codecommit, Transfer Server, Kinesis Streams, Kinesis Firehose, SageMaker(Notebook, Runtime, API),
2323
CloudFormation, CodePipeline, Storage Gateway, AppMesh, Transfer, Service Catalog, AppStream,
24-
Athena, Rekognition
24+
Athena, Rekognition, Elastic File System (EFS), Cloud Directory
2525

2626
* [RDS DB Subnet Group](https://www.terraform.io/docs/providers/aws/r/db_subnet_group.html)
2727
* [ElastiCache Subnet Group](https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html)
@@ -226,6 +226,9 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
226226
| athena\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for Athena endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list(string) | `[]` | no |
227227
| azs | A list of availability zones in the region | list(string) | `[]` | no |
228228
| cidr | The CIDR block for the VPC. Default value is a valid CIDR, but not acceptable by AWS and should be overridden | string | `"0.0.0.0/0"` | no |
229+
| cloud\_directory\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for Cloud Directory endpoint | bool | `"false"` | no |
230+
| cloud\_directory\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for Cloud Directory endpoint | list(string) | `[]` | no |
231+
| cloud\_directory\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for Cloud Directory endpoint. Only a single subnet within an AZ is supported. Ifomitted, private subnets will be used. | list(string) | `[]` | no |
229232
| cloudformation\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for Cloudformation endpoint | bool | `"false"` | no |
230233
| cloudformation\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for Cloudformation endpoint | list(string) | `[]` | no |
231234
| cloudformation\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for Cloudformation endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list(string) | `[]` | no |
@@ -300,6 +303,9 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
300303
| ecs\_telemetry\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for ECS Telemetry endpoint | bool | `"false"` | no |
301304
| ecs\_telemetry\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for ECS Telemetry endpoint | list(string) | `[]` | no |
302305
| ecs\_telemetry\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for ECS Telemetry endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list(string) | `[]` | no |
306+
| efs\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for EFS endpoint | bool | `"false"` | no |
307+
| efs\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for EFS endpoint | list(string) | `[]` | no |
308+
| efs\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for EFS endpoint. Only a single subnet within an AZ is supported. Ifomitted, private subnets will be used. | list(string) | `[]` | no |
303309
| elasticache\_acl\_tags | Additional tags for the elasticache subnets network ACL | map(string) | `{}` | no |
304310
| elasticache\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for elasticache subnets | bool | `"false"` | no |
305311
| elasticache\_inbound\_acl\_rules | Elasticache subnets inbound network ACL rules | list(map(string)) | `[ { "cidr_block": "0.0.0.0/0", "from_port": 0, "protocol": "-1", "rule_action": "allow", "rule_number": 100, "to_port": 0 } ]` | no |
@@ -319,6 +325,7 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
319325
| enable\_athena\_endpoint | Should be true if you want to provision a Athena endpoint to the VPC | bool | `"false"` | no |
320326
| enable\_classiclink | Should be true to enable ClassicLink for the VPC. Only valid in regions and accounts that support EC2 Classic. | bool | `"null"` | no |
321327
| enable\_classiclink\_dns\_support | Should be true to enable ClassicLink DNS Support for the VPC. Only valid in regions and accounts that support EC2 Classic. | bool | `"null"` | no |
328+
| enable\_cloud\_directory\_endpoint | Should be true if you want to provision an Cloud Directory endpoint to the VPC | bool | `"false"` | no |
322329
| enable\_cloudformation\_endpoint | Should be true if you want to provision a Cloudformation endpoint to the VPC | bool | `"false"` | no |
323330
| enable\_cloudtrail\_endpoint | Should be true if you want to provision a CloudTrail endpoint to the VPC | bool | `"false"` | no |
324331
| enable\_codebuild\_endpoint | Should be true if you want to provision an Codebuild endpoint to the VPC | string | `"false"` | no |
@@ -336,6 +343,7 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
336343
| enable\_ecs\_agent\_endpoint | Should be true if you want to provision a ECS Agent endpoint to the VPC | bool | `"false"` | no |
337344
| enable\_ecs\_endpoint | Should be true if you want to provision a ECS endpoint to the VPC | bool | `"false"` | no |
338345
| enable\_ecs\_telemetry\_endpoint | Should be true if you want to provision a ECS Telemetry endpoint to the VPC | bool | `"false"` | no |
346+
| enable\_efs\_endpoint | Should be true if you want to provision an EFS endpoint to the VPC | bool | `"false"` | no |
339347
| enable\_elasticloadbalancing\_endpoint | Should be true if you want to provision a Elastic Load Balancing endpoint to the VPC | bool | `"false"` | no |
340348
| enable\_events\_endpoint | Should be true if you want to provision a CloudWatch Events endpoint to the VPC | bool | `"false"` | no |
341349
| enable\_git\_codecommit\_endpoint | Should be true if you want to provision an Git Codecommit endpoint to the VPC | string | `"false"` | no |
@@ -573,6 +581,9 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
573581
| vpc\_endpoint\_athena\_dns\_entry | The DNS entries for the VPC Endpoint for Athena. |
574582
| vpc\_endpoint\_athena\_id | The ID of VPC endpoint for Athena |
575583
| vpc\_endpoint\_athena\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for Athena. |
584+
| vpc\_endpoint\_cloud\_directory\_dns\_entry | The DNS entries for the VPC Endpoint for Cloud Directory. |
585+
| vpc\_endpoint\_cloud\_directory\_id | The ID of VPC endpoint for Cloud Directory |
586+
| vpc\_endpoint\_cloud\_directory\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for Cloud Directory. |
576587
| vpc\_endpoint\_cloudformation\_dns\_entry | The DNS entries for the VPC Endpoint for Cloudformation. |
577588
| vpc\_endpoint\_cloudformation\_id | The ID of VPC endpoint for Cloudformation |
578589
| vpc\_endpoint\_cloudformation\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for Cloudformation. |
@@ -614,6 +625,9 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
614625
| vpc\_endpoint\_ecs\_telemetry\_dns\_entry | The DNS entries for the VPC Endpoint for ECS Telemetry. |
615626
| vpc\_endpoint\_ecs\_telemetry\_id | The ID of VPC endpoint for ECS Telemetry |
616627
| vpc\_endpoint\_ecs\_telemetry\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for ECS Telemetry. |
628+
| vpc\_endpoint\_efs\_dns\_entry | The DNS entries for the VPC Endpoint for EFS. |
629+
| vpc\_endpoint\_efs\_id | The ID of VPC endpoint for EFS |
630+
| vpc\_endpoint\_efs\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for EFS. |
617631
| vpc\_endpoint\_elasticloadbalancing\_dns\_entry | The DNS entries for the VPC Endpoint for Elastic Load Balancing. |
618632
| vpc\_endpoint\_elasticloadbalancing\_id | The ID of VPC endpoint for Elastic Load Balancing |
619633
| vpc\_endpoint\_elasticloadbalancing\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for Elastic Load Balancing. |

outputs.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,37 @@ output "vpc_endpoint_rekognition_dns_entry" {
962962
value = flatten(aws_vpc_endpoint.rekognition.*.dns_entry)
963963
}
964964

965+
output "vpc_endpoint_efs_id" {
966+
description = "The ID of VPC endpoint for EFS"
967+
value = concat(aws_vpc_endpoint.efs.*.id, [""])[0]
968+
}
969+
970+
output "vpc_endpoint_efs_network_interface_ids" {
971+
description = "One or more network interfaces for the VPC Endpoint for EFS."
972+
value = flatten(aws_vpc_endpoint.efs.*.network_interface_ids)
973+
}
974+
975+
output "vpc_endpoint_efs_dns_entry" {
976+
description = "The DNS entries for the VPC Endpoint for EFS."
977+
value = flatten(aws_vpc_endpoint.efs.*.dns_entry)
978+
}
979+
980+
output "vpc_endpoint_cloud_directory_id" {
981+
description = "The ID of VPC endpoint for Cloud Directory"
982+
value = concat(aws_vpc_endpoint.cloud_directory.*.id, [""])[0]
983+
}
984+
985+
output "vpc_endpoint_cloud_directory_network_interface_ids" {
986+
description = "One or more network interfaces for the VPC Endpoint for Cloud Directory."
987+
value = flatten(aws_vpc_endpoint.cloud_directory.*.network_interface_ids)
988+
}
989+
990+
output "vpc_endpoint_cloud_directory_dns_entry" {
991+
description = "The DNS entries for the VPC Endpoint for Cloud Directory."
992+
value = flatten(aws_vpc_endpoint.cloud_directory.*.dns_entry)
993+
}
994+
995+
965996
# Static values (arguments)
966997
output "azs" {
967998
description = "A list of availability zones specified as argument to this module"

variables.tf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,55 @@ variable "rekognition_endpoint_private_dns_enabled" {
12501250
default = false
12511251
}
12521252

1253+
variable "enable_efs_endpoint" {
1254+
description = "Should be true if you want to provision an EFS endpoint to the VPC"
1255+
type = bool
1256+
default = false
1257+
}
1258+
1259+
variable "efs_endpoint_security_group_ids" {
1260+
description = "The ID of one or more security groups to associate with the network interface for EFS endpoint"
1261+
type = list(string)
1262+
default = []
1263+
}
1264+
1265+
variable "efs_endpoint_subnet_ids" {
1266+
description = "The ID of one or more subnets in which to create a network interface for EFS endpoint. Only a single subnet within an AZ is supported. Ifomitted, private subnets will be used."
1267+
type = list(string)
1268+
default = []
1269+
}
1270+
1271+
variable "efs_endpoint_private_dns_enabled" {
1272+
description = "Whether or not to associate a private hosted zone with the specified VPC for EFS endpoint"
1273+
type = bool
1274+
default = false
1275+
}
1276+
1277+
variable "enable_cloud_directory_endpoint" {
1278+
description = "Should be true if you want to provision an Cloud Directory endpoint to the VPC"
1279+
type = bool
1280+
default = false
1281+
}
1282+
1283+
variable "cloud_directory_endpoint_security_group_ids" {
1284+
description = "The ID of one or more security groups to associate with the network interface for Cloud Directory endpoint"
1285+
type = list(string)
1286+
default = []
1287+
}
1288+
1289+
variable "cloud_directory_endpoint_subnet_ids" {
1290+
description = "The ID of one or more subnets in which to create a network interface for Cloud Directory endpoint. Only a single subnet within an AZ is supported. Ifomitted, private subnets will be used."
1291+
type = list(string)
1292+
default = []
1293+
}
1294+
1295+
variable "cloud_directory_endpoint_private_dns_enabled" {
1296+
description = "Whether or not to associate a private hosted zone with the specified VPC for Cloud Directory endpoint"
1297+
type = bool
1298+
default = false
1299+
}
1300+
1301+
12531302
variable "map_public_ip_on_launch" {
12541303
description = "Should be false if you do not want to auto-assign public IP on launch"
12551304
type = bool

vpc-endpoints.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,3 +957,49 @@ resource "aws_vpc_endpoint" "rekognition" {
957957
private_dns_enabled = var.rekognition_endpoint_private_dns_enabled
958958
tags = local.vpce_tags
959959
}
960+
961+
#######################
962+
# VPC Endpoint for EFS
963+
#######################
964+
data "aws_vpc_endpoint_service" "efs" {
965+
count = var.create_vpc && var.enable_efs_endpoint ? 1 : 0
966+
967+
service = "elasticfilesystem"
968+
}
969+
970+
resource "aws_vpc_endpoint" "efs" {
971+
count = var.create_vpc && var.enable_efs_endpoint ? 1 : 0
972+
973+
vpc_id = local.vpc_id
974+
service_name = data.aws_vpc_endpoint_service.efs.service_name
975+
vpc_endpoint_type = "Interface"
976+
977+
security_group_ids = var.efs_endpoint_security_group_ids
978+
subnet_ids = coalescelist(var.efs_endpoint_subnet_ids, aws_subnet.private.*.id)
979+
private_dns_enabled = var.efs_endpoint_private_dns_enabled
980+
981+
tags = local.vpce_tags
982+
}
983+
984+
#######################
985+
# VPC Endpoint for Cloud Directory
986+
#######################
987+
data "aws_vpc_endpoint_service" "cloud_directory" {
988+
count = var.create_vpc && var.enable_cloud_directory_endpoint ? 1 : 0
989+
990+
service = "clouddirectory"
991+
}
992+
993+
resource "aws_vpc_endpoint" "cloud_directory" {
994+
count = var.create_vpc && var.enable_cloud_directory_endpoint ? 1 : 0
995+
996+
vpc_id = local.vpc_id
997+
service_name = data.aws_vpc_endpoint_service.cloud_directory.service_name
998+
vpc_endpoint_type = "Interface"
999+
1000+
security_group_ids = var.cloud_directory_endpoint_security_group_ids
1001+
subnet_ids = coalescelist(var.cloud_directory_endpoint_subnet_ids, aws_subnet.private.*.id)
1002+
private_dns_enabled = var.cloud_directory_endpoint_private_dns_enabled
1003+
1004+
tags = local.vpce_tags
1005+
}

0 commit comments

Comments
 (0)