Skip to content

Commit 881211d

Browse files
committed
Added Ec2 Auto Scaling vpc endpoint
1 parent b76606e commit 881211d

File tree

4 files changed

+71
-6
lines changed

4 files changed

+71
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ These types of resources are supported:
1616
* [VPN Gateway](https://www.terraform.io/docs/providers/aws/r/vpn_gateway.html)
1717
* [VPC Endpoint](https://www.terraform.io/docs/providers/aws/r/vpc_endpoint.html):
1818
* Gateway: S3, DynamoDB
19-
* Interface: EC2, SSM, EC2 Messages, SSM Messages, SQS, ECR API, ECR DKR, API Gateway, KMS,
20-
ECS, ECS Agent, ECS Telemetry, SNS, STS, Glue, CloudWatch(Monitoring, Logs, Events),
21-
Elastic Load Balancing, CloudTrail, Secrets Manager, Config, CodeBuild, CodeCommit,
22-
Git-Codecommit, Transfer Server, Kinesis Streams, Kinesis Firehose, SageMaker(Notebook, Runtime, API),
23-
CloudFormation, CodePipeline, Storage Gateway, AppMesh, Transfer, Service Catalog, AppStream,
24-
Athena, Rekognition, Elastic File System (EFS), Cloud Directory
19+
* Interface: EC2, SSM, EC2 Messages, EC2 AutoScaling, SSM Messages, SQS, ECR API, ECR DKR, API Gateway, KMS, ECS, ECS Agent, ECS Telemetry, SNS, STS, Glue, CloudWatch(Monitoring, Logs,Events), Elastic Load Balancing, CloudTrail, Secrets Manager, Config, CodeBuild, CodeCommit, Git-Codecommit, Transfer Server, Kinesis Streams, Kinesis Firehose, SageMaker(Notebook, Runtime, API), CloudFormation, CodePipeline, Storage Gateway, AppMesh, Transfer, Service Catalog, AppStream, Athena, Rekognition, Elastic File System (EFS), Cloud Directory
2520

2621
* [RDS DB Subnet Group](https://www.terraform.io/docs/providers/aws/r/db_subnet_group.html)
2722
* [ElastiCache Subnet Group](https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html)
@@ -290,6 +285,9 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
290285
| ec2messages\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for EC2MESSAGES endpoint | bool | `"false"` | no |
291286
| ec2messages\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for EC2MESSAGES endpoint | list(string) | `[]` | no |
292287
| ec2messages\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for EC2MESSAGES endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list(string) | `[]` | no |
288+
| 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 |
289+
| 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 |
290+
| 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 |
293291
| ecr\_api\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for ECR API endpoint | bool | `"false"` | no |
294292
| ecr\_api\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for ECR API endpoint | list(string) | `[]` | no |
295293
| ecr\_api\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for ECR api endpoint. If omitted, private subnets will be used. | list(string) | `[]` | no |
@@ -340,6 +338,7 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
340338
| enable\_dynamodb\_endpoint | Should be true if you want to provision a DynamoDB endpoint to the VPC | bool | `"false"` | no |
341339
| enable\_ec2\_endpoint | Should be true if you want to provision an EC2 endpoint to the VPC | bool | `"false"` | no |
342340
| enable\_ec2messages\_endpoint | Should be true if you want to provision an EC2MESSAGES endpoint to the VPC | bool | `"false"` | no |
341+
| enable\_ec2\_autoscaling\_endpoint | Should be true if you want to provision an EC2AutoScaling endpoint to the VPC | bool | `"false"` | no |
343342
| enable\_ecr\_api\_endpoint | Should be true if you want to provision an ecr api endpoint to the VPC | bool | `"false"` | no |
344343
| enable\_ecr\_dkr\_endpoint | Should be true if you want to provision an ecr dkr endpoint to the VPC | bool | `"false"` | no |
345344
| enable\_ecs\_agent\_endpoint | Should be true if you want to provision a ECS Agent endpoint to the VPC | bool | `"false"` | no |
@@ -614,6 +613,9 @@ Sometimes it is handy to have public access to Redshift clusters (for example if
614613
| vpc\_endpoint\_ec2messages\_dns\_entry | The DNS entries for the VPC Endpoint for EC2MESSAGES. |
615614
| vpc\_endpoint\_ec2messages\_id | The ID of VPC endpoint for EC2MESSAGES |
616615
| vpc\_endpoint\_ec2messages\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for EC2MESSAGES |
616+
| vpc\_endpoint\_ec2\_autoscaling\_dns\_entry | The DNS entries for the VPC Endpoint for EC2 AutoScaling. |
617+
| vpc\_endpoint\_ec2\_autoscaling\_id | The ID of VPC endpoint for EC2 AutoScaling |
618+
| vpc\_endpoint\_ec2\_autoscaling\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for EC2 AutoScaling |
617619
| vpc\_endpoint\_ecr\_api\_dns\_entry | The DNS entries for the VPC Endpoint for ECR API. |
618620
| vpc\_endpoint\_ecr\_api\_id | The ID of VPC endpoint for ECR API |
619621
| vpc\_endpoint\_ecr\_api\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for ECR API. |

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)