Skip to content

Commit a4a412e

Browse files
authored
Merge pull request #205 from tbugfinder/extend_endpoints
Extend endpoints for AWS Systems Manager use
2 parents 8e2f50e + 3caad32 commit a4a412e

File tree

5 files changed

+138
-4
lines changed

5 files changed

+138
-4
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ Terraform version 0.10.3 or newer is required for this module to work.
211211
| ec2\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for EC2 endpoint | string | `"false"` | no |
212212
| ec2\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for EC2 endpoint | list | `[]` | no |
213213
| 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 | `[]` | no |
214+
| ec2messages\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for EC2MESSAGES endpoint | string | `"false"` | no |
215+
| ec2messages\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for EC2MESSAGES endpoint | list | `[]` | no |
216+
| 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 | `[]` | no |
214217
| elasticache\_route\_table\_tags | Additional tags for the elasticache route tables | map | `{}` | no |
215218
| elasticache\_subnet\_suffix | Suffix to append to elasticache subnets name | string | `"elasticache"` | no |
216219
| elasticache\_subnet\_tags | Additional tags for the elasticache subnets | map | `{}` | no |
@@ -220,9 +223,11 @@ Terraform version 0.10.3 or newer is required for this module to work.
220223
| enable\_dns\_support | Should be true to enable DNS support in the VPC | string | `"true"` | no |
221224
| enable\_dynamodb\_endpoint | Should be true if you want to provision a DynamoDB endpoint to the VPC | string | `"false"` | no |
222225
| enable\_ec2\_endpoint | Should be true if you want to provision an EC2 endpoint to the VPC | string | `"false"` | no |
226+
| enable\_ec2messages\_endpoint | Should be true if you want to provision an EC2MESSAGES endpoint to the VPC | string | `"false"` | no |
223227
| enable\_nat\_gateway | Should be true if you want to provision NAT Gateways for each of your private networks | string | `"false"` | no |
224228
| enable\_s3\_endpoint | Should be true if you want to provision an S3 endpoint to the VPC | string | `"false"` | no |
225229
| enable\_ssm\_endpoint | Should be true if you want to provision an SSM endpoint to the VPC | string | `"false"` | no |
230+
| enable\_ssmmessages\_endpoint | Should be true if you want to provision a SSMMESSAGES endpoint to the VPC | string | `"false"` | no |
226231
| enable\_vpn\_gateway | Should be true if you want to create a new VPN Gateway resource and attach it to the VPC | string | `"false"` | no |
227232
| external\_nat\_ip\_ids | List of EIP IDs to be assigned to the NAT Gateways (used in combination with reuse_nat_ips) | list | `[]` | no |
228233
| igw\_tags | Additional tags for the internet gateway | map | `{}` | no |
@@ -257,6 +262,9 @@ Terraform version 0.10.3 or newer is required for this module to work.
257262
| ssm\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for SSM endpoint | string | `"false"` | no |
258263
| ssm\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for SSM endpoint | list | `[]` | no |
259264
| ssm\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for SSM endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list | `[]` | no |
265+
| ssmmessages\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for SSMMESSAGES endpoint | string | `"false"` | no |
266+
| ssmmessages\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for SSMMESSAGES endpoint | list | `[]` | no |
267+
| 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 |
260268
| tags | A map of tags to add to all resources | map | `{}` | no |
261269
| vpc\_tags | Additional tags for the VPC | map | `{}` | no |
262270
| vpn\_gateway\_id | ID of VPN Gateway to attach to the VPC | string | `""` | no |
@@ -314,11 +322,17 @@ Terraform version 0.10.3 or newer is required for this module to work.
314322
| vpc\_endpoint\_ec2\_dns\_entry | The DNS entries for the VPC Endpoint for EC2. |
315323
| vpc\_endpoint\_ec2\_id | The ID of VPC endpoint for EC2 |
316324
| vpc\_endpoint\_ec2\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for EC2 |
325+
| vpc\_endpoint\_ec2messages\_dns\_entry | The DNS entries for the VPC Endpoint for EC2MESSAGES. |
326+
| vpc\_endpoint\_ec2messages\_id | The ID of VPC endpoint for EC2MESSAGES |
327+
| vpc\_endpoint\_ec2messages\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for EC2MESSAGES |
317328
| vpc\_endpoint\_s3\_id | The ID of VPC endpoint for S3 |
318329
| vpc\_endpoint\_s3\_pl\_id | The prefix list for the S3 VPC endpoint. |
319330
| vpc\_endpoint\_ssm\_dns\_entry | The DNS entries for the VPC Endpoint for SSM. |
320331
| vpc\_endpoint\_ssm\_id | The ID of VPC endpoint for SSM |
321332
| vpc\_endpoint\_ssm\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for SSM. |
333+
| vpc\_endpoint\_ssmmessages\_dns\_entry | The DNS entries for the VPC Endpoint for SSMMESSAGES. |
334+
| vpc\_endpoint\_ssmmessages\_id | The ID of VPC endpoint for SSMMESSAGES |
335+
| vpc\_endpoint\_ssmmessages\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for SSMMESSAGES. |
322336
| vpc\_id | The ID of the VPC |
323337
| vpc\_instance\_tenancy | Tenancy of instances spin up within VPC |
324338
| vpc\_main\_route\_table\_id | The ID of the main route table associated with this VPC |

examples/complete-vpc/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,18 @@ module "vpc" {
4949

5050
// ssm_endpoint_subnet_ids = ["..."]
5151

52+
# VPC endpoint for SSMMESSAGES
53+
enable_ssmmessages_endpoint = true
54+
ssmmessages_endpoint_private_dns_enabled = true
55+
ssmmessages_endpoint_security_group_ids = ["${data.aws_security_group.default.id}"]
5256
# VPC Endpoint for EC2
5357
enable_ec2_endpoint = true
5458
ec2_endpoint_private_dns_enabled = true
5559
ec2_endpoint_security_group_ids = ["${data.aws_security_group.default.id}"]
60+
# VPC Endpoint for EC2MESSAGES
61+
enable_ec2messages_endpoint = true
62+
ec2messages_endpoint_private_dns_enabled = true
63+
ec2messages_endpoint_security_group_ids = ["${data.aws_security_group.default.id}"]
5664
tags = {
5765
Owner = "user"
5866
Environment = "staging"

main.tf

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ resource "aws_vpc_endpoint_route_table_association" "public_dynamodb" {
404404
route_table_id = "${aws_route_table.public.id}"
405405
}
406406

407-
######################
407+
#######################
408408
# VPC Endpoint for SSM
409-
######################
409+
#######################
410410
data "aws_vpc_endpoint_service" "ssm" {
411411
count = "${var.create_vpc && var.enable_ssm_endpoint ? 1 : 0}"
412412

@@ -425,9 +425,30 @@ resource "aws_vpc_endpoint" "ssm" {
425425
private_dns_enabled = "${var.ssm_endpoint_private_dns_enabled}"
426426
}
427427

428-
######################
428+
###############################
429+
# VPC Endpoint for SSMMESSAGES
430+
###############################
431+
data "aws_vpc_endpoint_service" "ssmmessages" {
432+
count = "${var.create_vpc && var.enable_ssmmessages_endpoint ? 1 : 0}"
433+
434+
service = "ssmmessages"
435+
}
436+
437+
resource "aws_vpc_endpoint" "ssmmessages" {
438+
count = "${var.create_vpc && var.enable_ssmmessages_endpoint ? 1 : 0}"
439+
440+
vpc_id = "${local.vpc_id}"
441+
service_name = "${data.aws_vpc_endpoint_service.ssmmessages.service_name}"
442+
vpc_endpoint_type = "Interface"
443+
444+
security_group_ids = ["${var.ssmmessages_endpoint_security_group_ids}"]
445+
subnet_ids = ["${coalescelist(var.ssmmessages_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
446+
private_dns_enabled = "${var.ssmmessages_endpoint_private_dns_enabled}"
447+
}
448+
449+
#######################
429450
# VPC Endpoint for EC2
430-
######################
451+
#######################
431452
data "aws_vpc_endpoint_service" "ec2" {
432453
count = "${var.create_vpc && var.enable_ec2_endpoint ? 1 : 0}"
433454

@@ -446,6 +467,27 @@ resource "aws_vpc_endpoint" "ec2" {
446467
private_dns_enabled = "${var.ec2_endpoint_private_dns_enabled}"
447468
}
448469

470+
###############################
471+
# VPC Endpoint for EC2MESSAGES
472+
###############################
473+
data "aws_vpc_endpoint_service" "ec2messages" {
474+
count = "${var.create_vpc && var.enable_ec2messages_endpoint ? 1 : 0}"
475+
476+
service = "ec2messages"
477+
}
478+
479+
resource "aws_vpc_endpoint" "ec2messages" {
480+
count = "${var.create_vpc && var.enable_ec2messages_endpoint ? 1 : 0}"
481+
482+
vpc_id = "${local.vpc_id}"
483+
service_name = "${data.aws_vpc_endpoint_service.ec2messages.service_name}"
484+
vpc_endpoint_type = "Interface"
485+
486+
security_group_ids = ["${var.ec2messages_endpoint_security_group_ids}"]
487+
subnet_ids = ["${coalescelist(var.ec2messages_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
488+
private_dns_enabled = "${var.ec2messages_endpoint_private_dns_enabled}"
489+
}
490+
449491
##########################
450492
# Route table association
451493
##########################

outputs.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,21 @@ output "vpc_endpoint_ssm_dns_entry" {
294294
value = "${flatten(aws_vpc_endpoint.ssm.*.dns_entry)}"
295295
}
296296

297+
output "vpc_endpoint_ssmmessages_id" {
298+
description = "The ID of VPC endpoint for SSMMESSAGES"
299+
value = "${element(concat(aws_vpc_endpoint.ssmmessages.*.id, list("")), 0)}"
300+
}
301+
302+
output "vpc_endpoint_ssmmessages_network_interface_ids" {
303+
description = "One or more network interfaces for the VPC Endpoint for SSMMESSAGES."
304+
value = "${flatten(aws_vpc_endpoint.ssmmessages.*.network_interface_ids)}"
305+
}
306+
307+
output "vpc_endpoint_ssmmessages_dns_entry" {
308+
description = "The DNS entries for the VPC Endpoint for SSMMESSAGES."
309+
value = "${flatten(aws_vpc_endpoint.ssmmessages.*.dns_entry)}"
310+
}
311+
297312
output "vpc_endpoint_ec2_id" {
298313
description = "The ID of VPC endpoint for EC2"
299314
value = "${element(concat(aws_vpc_endpoint.ec2.*.id, list("")), 0)}"
@@ -309,6 +324,21 @@ output "vpc_endpoint_ec2_dns_entry" {
309324
value = "${flatten(aws_vpc_endpoint.ec2.*.dns_entry)}"
310325
}
311326

327+
output "vpc_endpoint_ec2messages_id" {
328+
description = "The ID of VPC endpoint for EC2MESSAGES"
329+
value = "${element(concat(aws_vpc_endpoint.ec2messages.*.id, list("")), 0)}"
330+
}
331+
332+
output "vpc_endpoint_ec2messages_network_interface_ids" {
333+
description = "One or more network interfaces for the VPC Endpoint for EC2MESSAGES"
334+
value = "${flatten(aws_vpc_endpoint.ec2messages.*.network_interface_ids)}"
335+
}
336+
337+
output "vpc_endpoint_ec2messages_dns_entry" {
338+
description = "The DNS entries for the VPC Endpoint for EC2MESSAGES."
339+
value = "${flatten(aws_vpc_endpoint.ec2messages.*.dns_entry)}"
340+
}
341+
312342
# Static values (arguments)
313343
output "azs" {
314344
description = "A list of availability zones specified as argument to this module"

variables.tf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,26 @@ variable "ssm_endpoint_private_dns_enabled" {
198198
default = false
199199
}
200200

201+
variable "enable_ssmmessages_endpoint" {
202+
description = "Should be true if you want to provision a SSMMESSAGES endpoint to the VPC"
203+
default = false
204+
}
205+
206+
variable "ssmmessages_endpoint_security_group_ids" {
207+
description = "The ID of one or more security groups to associate with the network interface for SSMMESSAGES endpoint"
208+
default = []
209+
}
210+
211+
variable "ssmmessages_endpoint_subnet_ids" {
212+
description = "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."
213+
default = []
214+
}
215+
216+
variable "ssmmessages_endpoint_private_dns_enabled" {
217+
description = "Whether or not to associate a private hosted zone with the specified VPC for SSMMESSAGES endpoint"
218+
default = false
219+
}
220+
201221
variable "enable_ec2_endpoint" {
202222
description = "Should be true if you want to provision an EC2 endpoint to the VPC"
203223
default = false
@@ -218,6 +238,26 @@ variable "ec2_endpoint_subnet_ids" {
218238
default = []
219239
}
220240

241+
variable "enable_ec2messages_endpoint" {
242+
description = "Should be true if you want to provision an EC2MESSAGES endpoint to the VPC"
243+
default = false
244+
}
245+
246+
variable "ec2messages_endpoint_security_group_ids" {
247+
description = "The ID of one or more security groups to associate with the network interface for EC2MESSAGES endpoint"
248+
default = []
249+
}
250+
251+
variable "ec2messages_endpoint_private_dns_enabled" {
252+
description = "Whether or not to associate a private hosted zone with the specified VPC for EC2MESSAGES endpoint"
253+
default = false
254+
}
255+
256+
variable "ec2messages_endpoint_subnet_ids" {
257+
description = "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."
258+
default = []
259+
}
260+
221261
variable "map_public_ip_on_launch" {
222262
description = "Should be false if you do not want to auto-assign public IP on launch"
223263
default = true

0 commit comments

Comments
 (0)