Skip to content

Commit e82814f

Browse files
authored
feat: Add EC2 Auto Scaling VPC endpoint (#374)
1 parent 7302302 commit e82814f

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
304304
| dhcp\_options\_netbios\_node\_type | Specify netbios node\_type for DHCP options set (requires enable\_dhcp\_options set to true) | `string` | `""` | no |
305305
| dhcp\_options\_ntp\_servers | Specify a list of NTP servers for DHCP options set (requires enable\_dhcp\_options set to true) | `list(string)` | `[]` | no |
306306
| dhcp\_options\_tags | Additional tags for the DHCP option set (requires enable\_dhcp\_options set to true) | `map(string)` | `{}` | no |
307+
| ec2\_autoscaling\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for EC2 AutoScaling endpoint | bool | `"false"` | no |
308+
| ec2\_autoscaling\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for EC2 AutoScaling endpoint | list(string) | `[]` | no |
309+
| ec2\_autoscaling\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for EC2 AutoScaling endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list(string) | `[]` | no |
307310
| ec2\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for EC2 endpoint | `bool` | `false` | no |
308311
| ec2\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for EC2 endpoint | `list(string)` | `[]` | no |
309312
| ec2\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for EC2 endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | `list(string)` | `[]` | no |
@@ -358,6 +361,7 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
358361
| enable\_dns\_hostnames | Should be true to enable DNS hostnames in the VPC | `bool` | `false` | no |
359362
| enable\_dns\_support | Should be true to enable DNS support in the VPC | `bool` | `true` | no |
360363
| enable\_dynamodb\_endpoint | Should be true if you want to provision a DynamoDB endpoint to the VPC | `bool` | `false` | no |
364+
| enable\_ec2\_autoscaling\_endpoint | Should be true if you want to provision an EC2AutoScaling endpoint to the VPC | bool | `"false"` | no |
361365
| enable\_ec2\_endpoint | Should be true if you want to provision an EC2 endpoint to the VPC | `bool` | `false` | no |
362366
| enable\_ec2messages\_endpoint | Should be true if you want to provision an EC2MESSAGES endpoint to the VPC | `bool` | `false` | no |
363367
| enable\_ecr\_api\_endpoint | Should be true if you want to provision an ecr api endpoint to the VPC | `bool` | `false` | no |
@@ -643,6 +647,9 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway
643647
| vpc\_endpoint\_ec2\_dns\_entry | The DNS entries for the VPC Endpoint for EC2. |
644648
| vpc\_endpoint\_ec2\_id | The ID of VPC endpoint for EC2 |
645649
| vpc\_endpoint\_ec2\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for EC2 |
650+
| vpc\_endpoint\_ec2\_autoscaling\_dns\_entry | The DNS entries for the VPC Endpoint for EC2 AutoScaling. |
651+
| vpc\_endpoint\_ec2\_autoscaling\_id | The ID of VPC endpoint for EC2 AutoScaling |
652+
| vpc\_endpoint\_ec2\_autoscaling\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for EC2 AutoScaling |
646653
| vpc\_endpoint\_ec2messages\_dns\_entry | The DNS entries for the VPC Endpoint for EC2MESSAGES. |
647654
| vpc\_endpoint\_ec2messages\_id | The ID of VPC endpoint for EC2MESSAGES |
648655
| vpc\_endpoint\_ec2messages\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for EC2MESSAGES |

outputs.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,21 @@ output "vpc_endpoint_ec2messages_dns_entry" {
543543
value = flatten(aws_vpc_endpoint.ec2messages.*.dns_entry)
544544
}
545545

546+
output "vpc_endpoint_ec2_autoscaling_id" {
547+
description = "The ID of VPC endpoint for EC2 Autoscaling"
548+
value = concat(aws_vpc_endpoint.ec2_autoscaling.*.id, [""])[0]
549+
}
550+
551+
output "vpc_endpoint_ec2_autoscaling_network_interface_ids" {
552+
description = "One or more network interfaces for the VPC Endpoint for EC2 Autoscaling"
553+
value = flatten(aws_vpc_endpoint.ec2_autoscaling.*.network_interface_ids)
554+
}
555+
556+
output "vpc_endpoint_ec2_autoscaling_dns_entry" {
557+
description = "The DNS entries for the VPC Endpoint for EC2 Autoscaling."
558+
value = flatten(aws_vpc_endpoint.ec2_autoscaling.*.dns_entry)
559+
}
560+
546561
output "vpc_endpoint_transferserver_id" {
547562
description = "The ID of VPC endpoint for transferserver"
548563
value = concat(aws_vpc_endpoint.transferserver.*.id, [""])[0]

variables.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,31 @@ variable "ec2messages_endpoint_subnet_ids" {
579579
default = []
580580
}
581581

582+
583+
variable "enable_ec2_autoscaling_endpoint" {
584+
description = "Should be true if you want to provision an EC2 Autoscaling endpoint to the VPC"
585+
type = bool
586+
default = false
587+
}
588+
589+
variable "ec2_autoscaling_endpoint_security_group_ids" {
590+
description = "The ID of one or more security groups to associate with the network interface for EC2 Autoscaling endpoint"
591+
type = list(string)
592+
default = []
593+
}
594+
595+
variable "ec2_autoscaling_endpoint_private_dns_enabled" {
596+
description = "Whether or not to associate a private hosted zone with the specified VPC for EC2 Autoscaling endpoint"
597+
type = bool
598+
default = false
599+
}
600+
601+
variable "ec2_autoscaling_endpoint_subnet_ids" {
602+
description = "The ID of one or more subnets in which to create a network interface for EC2 Autoscaling endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used."
603+
type = list(string)
604+
default = []
605+
}
606+
582607
variable "enable_ecr_api_endpoint" {
583608
description = "Should be true if you want to provision an ecr api endpoint to the VPC"
584609
type = bool

vpc-endpoints.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,29 @@ resource "aws_vpc_endpoint" "ec2messages" {
295295
tags = local.vpce_tags
296296
}
297297

298+
###############################
299+
# VPC Endpoint for EC2 Autoscaling
300+
###############################
301+
data "aws_vpc_endpoint_service" "ec2_autoscaling" {
302+
count = var.create_vpc && var.enable_ec2_autoscaling_endpoint ? 1 : 0
303+
304+
service = "autoscaling"
305+
}
306+
307+
resource "aws_vpc_endpoint" "ec2_autoscaling" {
308+
count = var.create_vpc && var.enable_ec2_autoscaling_endpoint ? 1 : 0
309+
310+
vpc_id = local.vpc_id
311+
service_name = data.aws_vpc_endpoint_service.ec2_autoscaling[0].service_name
312+
vpc_endpoint_type = "Interface"
313+
314+
security_group_ids = var.ec2_autoscaling_endpoint_security_group_ids
315+
subnet_ids = coalescelist(var.ec2_autoscaling_endpoint_subnet_ids, aws_subnet.private.*.id)
316+
private_dns_enabled = var.ec2_autoscaling_endpoint_private_dns_enabled
317+
tags = local.vpce_tags
318+
}
319+
320+
298321
###################################
299322
# VPC Endpoint for Transfer Server
300323
###################################

0 commit comments

Comments
 (0)