Skip to content

Commit 03e8c62

Browse files
DrFaust92antonbabenko
authored andcommitted
* add ecs vpc endpoints * add ecs vpcendpoints outputs * add ecs vpc endpoints to readme inputs/outputs table * add ecs vpc endpoints to readme endpoint list
1 parent c1395dd commit 03e8c62

File tree

4 files changed

+190
-1
lines changed

4 files changed

+190
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +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, ECR API, ECR DKR, API Gateway, KMS
19+
* Interface: EC2, SSM, EC2 Messages, SSM Messages, ECR API, ECR DKR, API Gateway, KMS, ECS, ECS Agent, ECS Telemetry
2020
* [RDS DB Subnet Group](https://www.terraform.io/docs/providers/aws/r/db_subnet_group.html)
2121
* [ElastiCache Subnet Group](https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html)
2222
* [Redshift Subnet Group](https://www.terraform.io/docs/providers/aws/r/redshift_subnet_group.html)
@@ -333,6 +333,15 @@ Terraform version 0.10.3 or newer is required for this module to work.
333333
| ssmmessages\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for SSMMESSAGES endpoint | string | `"false"` | no |
334334
| ssmmessages\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for SSMMESSAGES endpoint | list | `[]` | no |
335335
| ssmmessages\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for SSMMESSAGES endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list | `[]` | no |
336+
| ecs\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for ECS endpoint | string | `"false"` | no |
337+
| ecs\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for ECS endpoint | list | `[]` | no |
338+
| ecs\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for ECS endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list | `[]` | no |
339+
| ecs\_agent\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for ECS Agent endpoint | string | `"false"` | no |
340+
| ecs\_agent\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for ECS Agent endpoint | list | `[]` | no |
341+
| ecs\_agent\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for ECS Agent endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list | `[]` | no |
342+
| ecs\_telemetry\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for ECS Telemetry endpoint | string | `"false"` | no |
343+
| 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 | `[]` | no |
344+
| 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 | `[]` | no |
336345
| tags | A map of tags to add to all resources | map | `{}` | no |
337346
| vpc\_tags | Additional tags for the VPC | map | `{}` | no |
338347
| vpn\_gateway\_id | ID of VPN Gateway to attach to the VPC | string | `""` | no |
@@ -426,6 +435,15 @@ Terraform version 0.10.3 or newer is required for this module to work.
426435
| vpc\_endpoint\_ssmmessages\_dns\_entry | The DNS entries for the VPC Endpoint for SSMMESSAGES. |
427436
| vpc\_endpoint\_ssmmessages\_id | The ID of VPC endpoint for SSMMESSAGES |
428437
| vpc\_endpoint\_ssmmessages\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for SSMMESSAGES. |
438+
| vpc\_endpoint\_ecs\_dns\_entry | The DNS entries for the VPC Endpoint for ECS. |
439+
| vpc\_endpoint\_ecs\_id | The ID of VPC endpoint for ECS |
440+
| vpc\_endpoint\_ecs\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for ECS. |
441+
| vpc\_endpoint\_ecs\_agent\_dns\_entry | The DNS entries for the VPC Endpoint for ECS Agent. |
442+
| vpc\_endpoint\_ecs\_agent\_id | The ID of VPC endpoint for ECS Agent |
443+
| vpc\_endpoint\_ecs\_agent\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for ECS Agent. |
444+
| vpc\_endpoint\_ecs\_telemetry\_dns\_entry | The DNS entries for the VPC Endpoint for ECS Telemetry. |
445+
| vpc\_endpoint\_ecs\_telemetry\_id | The ID of VPC endpoint for ECS Telemetry |
446+
| vpc\_endpoint\_ecs\_telemetry\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for ECS Telemetry. |
429447
| vpc\_id | The ID of the VPC |
430448
| vpc\_instance\_tenancy | Tenancy of instances spin up within VPC |
431449
| vpc\_main\_route\_table\_id | The ID of the main route table associated with this VPC |

main.tf

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,72 @@ resource "aws_vpc_endpoint" "kms" {
830830
private_dns_enabled = "${var.kms_endpoint_private_dns_enabled}"
831831
}
832832

833+
834+
#######################
835+
# VPC Endpoint for ECS
836+
#######################
837+
data "aws_vpc_endpoint_service" "ecs" {
838+
count = "${var.create_vpc && var.enable_ecs_endpoint ? 1 : 0}"
839+
840+
service = "ecs"
841+
}
842+
843+
resource "aws_vpc_endpoint" "ecs" {
844+
count = "${var.create_vpc && var.enable_ecs_endpoint ? 1 : 0}"
845+
846+
vpc_id = "${local.vpc_id}"
847+
service_name = "${data.aws_vpc_endpoint_service.ecs.service_name}"
848+
vpc_endpoint_type = "Interface"
849+
850+
security_group_ids = ["${var.ecs_endpoint_security_group_ids}"]
851+
subnet_ids = ["${coalescelist(var.ecs_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
852+
private_dns_enabled = "${var.ecs_endpoint_private_dns_enabled}"
853+
}
854+
855+
856+
#######################
857+
# VPC Endpoint for ECS Agent
858+
#######################
859+
data "aws_vpc_endpoint_service" "ecs_agent" {
860+
count = "${var.create_vpc && var.enable_ecs_agent_endpoint ? 1 : 0}"
861+
862+
service = "ecs-agent"
863+
}
864+
865+
resource "aws_vpc_endpoint" "ecs_agent" {
866+
count = "${var.create_vpc && var.enable_ecs_agent_endpoint ? 1 : 0}"
867+
868+
vpc_id = "${local.vpc_id}"
869+
service_name = "${data.aws_vpc_endpoint_service.ecs_agent.service_name}"
870+
vpc_endpoint_type = "Interface"
871+
872+
security_group_ids = ["${var.ecs_agent_endpoint_security_group_ids}"]
873+
subnet_ids = ["${coalescelist(var.ecs_agent_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
874+
private_dns_enabled = "${var.ecs_agent_endpoint_private_dns_enabled}"
875+
}
876+
877+
878+
#######################
879+
# VPC Endpoint for ECS Telemetry
880+
#######################
881+
data "aws_vpc_endpoint_service" "ecs_telemetry" {
882+
count = "${var.create_vpc && var.enable_ecs_telemetry_endpoint ? 1 : 0}"
883+
884+
service = "ecs-telemetry"
885+
}
886+
887+
resource "aws_vpc_endpoint" "ecs_telemetry" {
888+
count = "${var.create_vpc && var.enable_ecs_telemetry_endpoint ? 1 : 0}"
889+
890+
vpc_id = "${local.vpc_id}"
891+
service_name = "${data.aws_vpc_endpoint_service.ecs.service_name}"
892+
vpc_endpoint_type = "Interface"
893+
894+
security_group_ids = ["${var.ecs_telemetry_endpoint_security_group_ids}"]
895+
subnet_ids = ["${coalescelist(var.ecs_telemetry_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
896+
private_dns_enabled = "${var.ecs_telemetry_endpoint_private_dns_enabled}"
897+
}
898+
833899
##########################
834900
# Route table association
835901
##########################

outputs.tf

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,51 @@ output "vpc_endpoint_apigw_dns_entry" {
464464
value = "${flatten(aws_vpc_endpoint.apigw.*.dns_entry)}"
465465
}
466466

467+
output "vpc_endpoint_ecs_id" {
468+
description = "The ID of VPC endpoint for ECS"
469+
value = "${element(concat(aws_vpc_endpoint.ecs.*.id, list("")), 0)}"
470+
}
471+
472+
output "vpc_endpoint_ecs_network_interface_ids" {
473+
description = "One or more network interfaces for the VPC Endpoint for ECS."
474+
value = "${flatten(aws_vpc_endpoint.ecs.*.network_interface_ids)}"
475+
}
476+
477+
output "vpc_endpoint_ecs_dns_entry" {
478+
description = "The DNS entries for the VPC Endpoint for ECS."
479+
value = "${flatten(aws_vpc_endpoint.ecs.*.dns_entry)}"
480+
}
481+
482+
output "vpc_endpoint_ecs_agent_id" {
483+
description = "The ID of VPC endpoint for ECS Agent"
484+
value = "${element(concat(aws_vpc_endpoint.ecs_agent.*.id, list("")), 0)}"
485+
}
486+
487+
output "vpc_endpoint_ecs_agent_network_interface_ids" {
488+
description = "One or more network interfaces for the VPC Endpoint for ECS Agent."
489+
value = "${flatten(aws_vpc_endpoint.ecs_agent.*.network_interface_ids)}"
490+
}
491+
492+
output "vpc_endpoint_ecs_agent_dns_entry" {
493+
description = "The DNS entries for the VPC Endpoint for ECS Agent."
494+
value = "${flatten(aws_vpc_endpoint.ecs_agent.*.dns_entry)}"
495+
}
496+
497+
output "vpc_endpoint_ecs_telemetry_id" {
498+
description = "The ID of VPC endpoint for ECS Telemetry"
499+
value = "${element(concat(aws_vpc_endpoint.ecs_telemetry.*.id, list("")), 0)}"
500+
}
501+
502+
output "vpc_endpoint_ecs_telemetry_network_interface_ids" {
503+
description = "One or more network interfaces for the VPC Endpoint for ECS Telemetry."
504+
value = "${flatten(aws_vpc_endpoint.ecs_telemetry.*.network_interface_ids)}"
505+
}
506+
507+
output "vpc_endpoint_ecs_telemetry_dns_entry" {
508+
description = "The DNS entries for the VPC Endpoint for ECS Telemetry."
509+
value = "${flatten(aws_vpc_endpoint.ecs_telemetry.*.dns_entry)}"
510+
}
511+
467512
# Static values (arguments)
468513
output "azs" {
469514
description = "A list of availability zones specified as argument to this module"

variables.tf

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,66 @@ variable "kms_endpoint_private_dns_enabled" {
344344
default = false
345345
}
346346

347+
variable "enable_ecs_endpoint" {
348+
description = "Should be true if you want to provision a ECS endpoint to the VPC"
349+
default = false
350+
}
351+
352+
variable "ecs_endpoint_security_group_ids" {
353+
description = "The ID of one or more security groups to associate with the network interface for ECS endpoint"
354+
default = []
355+
}
356+
357+
variable "ecs_endpoint_subnet_ids" {
358+
description = "The ID of one or more subnets in which to create a network interface for ECS endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used."
359+
default = []
360+
}
361+
362+
variable "ecs_endpoint_private_dns_enabled" {
363+
description = "Whether or not to associate a private hosted zone with the specified VPC for ECS endpoint"
364+
default = false
365+
}
366+
367+
variable "enable_ecs_agent_endpoint" {
368+
description = "Should be true if you want to provision a ECS Agent endpoint to the VPC"
369+
default = false
370+
}
371+
372+
variable "ecs_agent_endpoint_security_group_ids" {
373+
description = "The ID of one or more security groups to associate with the network interface for ECS Agent endpoint"
374+
default = []
375+
}
376+
377+
variable "ecs_agent_endpoint_subnet_ids" {
378+
description = "The ID of one or more subnets in which to create a network interface for ECS Agent endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used."
379+
default = []
380+
}
381+
382+
variable "ecs_agent_endpoint_private_dns_enabled" {
383+
description = "Whether or not to associate a private hosted zone with the specified VPC for ECS Agent endpoint"
384+
default = false
385+
}
386+
387+
variable "enable_ecs_telemetry_endpoint" {
388+
description = "Should be true if you want to provision a ECS Telemetry endpoint to the VPC"
389+
default = false
390+
}
391+
392+
variable "ecs_telemetry_endpoint_security_group_ids" {
393+
description = "The ID of one or more security groups to associate with the network interface for ECS Telemetry endpoint"
394+
default = []
395+
}
396+
397+
variable "ecs_telemetry_endpoint_subnet_ids" {
398+
description = "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."
399+
default = []
400+
}
401+
402+
variable "ecs_telemetry_endpoint_private_dns_enabled" {
403+
description = "Whether or not to associate a private hosted zone with the specified VPC for ECS Telemetry endpoint"
404+
default = false
405+
}
406+
347407
variable "map_public_ip_on_launch" {
348408
description = "Should be false if you do not want to auto-assign public IP on launch"
349409
default = true

0 commit comments

Comments
 (0)