Skip to content

Commit 7c1aa52

Browse files
committed
Cleanup for Terraform 0.12 (closes #265, #228)
1 parent 9127d84 commit 7c1aa52

File tree

17 files changed

+336
-117
lines changed

17 files changed

+336
-117
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: v1.8.1
44
hooks:
55
- id: terraform_fmt
6-
- id: terraform_docs
6+
# - id: terraform_docs # not yet compatible with Terraform 0.12
77
- repo: git://github.com/pre-commit/pre-commit-hooks
88
rev: v2.1.0
99
hooks:

README.md

Lines changed: 35 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, SQS, 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)
@@ -28,6 +28,12 @@ Sponsored by [Cloudcraft - the best way to draw AWS diagrams](https://cloudcraft
2828

2929
<a href="https://cloudcraft.co/?utm_source=terraform-aws-vpc" target="_blank"><img src="https://raw.githubusercontent.com/antonbabenko/modules.tf-lambda/master/misc/cloudcraft-logo.png" alt="Cloudcraft - the best way to draw AWS diagrams" width="211" height="56" /></a>
3030

31+
## Terraform versions
32+
33+
For Terraform 0.12 use version `v2.*` of this module.
34+
35+
If you are using Terraform 0.11 you can use versions `v1.*`.
36+
3137
## Usage
3238

3339
```hcl
@@ -252,6 +258,15 @@ Terraform version 0.10.3 or newer is required for this module to work.
252258
| ecr\_dkr\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for ECR DKR endpoint | string | `"false"` | no |
253259
| ecr\_dkr\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for ECR DKR endpoint | list | `[]` | no |
254260
| ecr\_dkr\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for ECR dkr endpoint. If omitted, private subnets will be used. | list | `[]` | no |
261+
| 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 |
262+
| 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 |
263+
| 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 |
264+
| ecs\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for ECS endpoint | string | `"false"` | no |
265+
| ecs\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for ECS endpoint | list | `[]` | no |
266+
| 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 |
267+
| 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 |
268+
| 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 |
269+
| 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 |
255270
| elasticache\_acl\_tags | Additional tags for the elasticache subnets network ACL | map | `{}` | no |
256271
| elasticache\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for elasticache subnets | string | `"false"` | no |
257272
| elasticache\_inbound\_acl\_rules | Elasticache subnets inbound network ACL rules | list | `[ { "cidr_block": "0.0.0.0/0", "from_port": 0, "protocol": "-1", "rule_action": "allow", "rule_number": 100, "to_port": 0 } ]` | no |
@@ -269,10 +284,14 @@ Terraform version 0.10.3 or newer is required for this module to work.
269284
| enable\_ec2messages\_endpoint | Should be true if you want to provision an EC2MESSAGES endpoint to the VPC | string | `"false"` | no |
270285
| enable\_ecr\_api\_endpoint | Should be true if you want to provision an ecr api endpoint to the VPC | string | `"false"` | no |
271286
| enable\_ecr\_dkr\_endpoint | Should be true if you want to provision an ecr dkr endpoint to the VPC | string | `"false"` | no |
287+
| enable\_ecs\_agent\_endpoint | Should be true if you want to provision a ECS Agent endpoint to the VPC | string | `"false"` | no |
288+
| enable\_ecs\_endpoint | Should be true if you want to provision a ECS endpoint to the VPC | string | `"false"` | no |
289+
| enable\_ecs\_telemetry\_endpoint | Should be true if you want to provision a ECS Telemetry endpoint to the VPC | string | `"false"` | no |
272290
| enable\_kms\_endpoint | Should be true if you want to provision a KMS endpoint to the VPC | string | `"false"` | no |
273291
| enable\_nat\_gateway | Should be true if you want to provision NAT Gateways for each of your private networks | string | `"false"` | no |
274292
| enable\_public\_redshift | Controls if redshift should have public routing table | string | `"false"` | no |
275293
| enable\_s3\_endpoint | Should be true if you want to provision an S3 endpoint to the VPC | string | `"false"` | no |
294+
| enable\_sqs\_endpoint | Should be true if you want to provision an SQS endpoint to the VPC | string | `"false"` | no |
276295
| enable\_ssm\_endpoint | Should be true if you want to provision an SSM endpoint to the VPC | string | `"false"` | no |
277296
| enable\_ssmmessages\_endpoint | Should be true if you want to provision a SSMMESSAGES endpoint to the VPC | string | `"false"` | no |
278297
| 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 |
@@ -327,6 +346,9 @@ Terraform version 0.10.3 or newer is required for this module to work.
327346
| reuse\_nat\_ips | Should be true if you don't want EIPs to be created for your NAT Gateways and will instead pass them in via the 'external_nat_ip_ids' variable | string | `"false"` | no |
328347
| secondary\_cidr\_blocks | List of secondary CIDR blocks to associate with the VPC to extend the IP Address pool | list | `[]` | no |
329348
| single\_nat\_gateway | Should be true if you want to provision a single shared NAT Gateway across all of your private networks | string | `"false"` | no |
349+
| sqs\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for SQS endpoint | string | `"false"` | no |
350+
| sqs\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for SQS endpoint | list | `[]` | no |
351+
| sqs\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for SQS endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list | `[]` | no |
330352
| ssm\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for SSM endpoint | string | `"false"` | no |
331353
| ssm\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for SSM endpoint | list | `[]` | no |
332354
| 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 |
@@ -415,11 +437,23 @@ Terraform version 0.10.3 or newer is required for this module to work.
415437
| vpc\_endpoint\_ecr\_dkr\_dns\_entry | The DNS entries for the VPC Endpoint for ECR DKR. |
416438
| vpc\_endpoint\_ecr\_dkr\_id | The ID of VPC endpoint for ECR DKR |
417439
| vpc\_endpoint\_ecr\_dkr\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for ECR DKR. |
440+
| vpc\_endpoint\_ecs\_agent\_dns\_entry | The DNS entries for the VPC Endpoint for ECS Agent. |
441+
| vpc\_endpoint\_ecs\_agent\_id | The ID of VPC endpoint for ECS Agent |
442+
| vpc\_endpoint\_ecs\_agent\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for ECS Agent. |
443+
| vpc\_endpoint\_ecs\_dns\_entry | The DNS entries for the VPC Endpoint for ECS. |
444+
| vpc\_endpoint\_ecs\_id | The ID of VPC endpoint for ECS |
445+
| vpc\_endpoint\_ecs\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for ECS. |
446+
| vpc\_endpoint\_ecs\_telemetry\_dns\_entry | The DNS entries for the VPC Endpoint for ECS Telemetry. |
447+
| vpc\_endpoint\_ecs\_telemetry\_id | The ID of VPC endpoint for ECS Telemetry |
448+
| vpc\_endpoint\_ecs\_telemetry\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for ECS Telemetry. |
418449
| vpc\_endpoint\_kms\_dns\_entry | The DNS entries for the VPC Endpoint for KMS. |
419450
| vpc\_endpoint\_kms\_id | The ID of VPC endpoint for KMS |
420451
| vpc\_endpoint\_kms\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for KMS. |
421452
| vpc\_endpoint\_s3\_id | The ID of VPC endpoint for S3 |
422453
| vpc\_endpoint\_s3\_pl\_id | The prefix list for the S3 VPC endpoint. |
454+
| vpc\_endpoint\_sqs\_dns\_entry | The DNS entries for the VPC Endpoint for SQS. |
455+
| vpc\_endpoint\_sqs\_id | The ID of VPC endpoint for SQS |
456+
| vpc\_endpoint\_sqs\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for SQS. |
423457
| vpc\_endpoint\_ssm\_dns\_entry | The DNS entries for the VPC Endpoint for SSM. |
424458
| vpc\_endpoint\_ssm\_id | The ID of VPC endpoint for SSM |
425459
| vpc\_endpoint\_ssm\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for SSM. |

examples/complete-vpc/main.tf

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module "vpc" {
4545
# VPC endpoint for SSM
4646
enable_ssm_endpoint = true
4747
ssm_endpoint_private_dns_enabled = true
48-
ssm_endpoint_security_group_ids = [data.aws_security_group.default.id] # ssm_endpoint_subnet_ids = ["..."]
48+
ssm_endpoint_security_group_ids = [data.aws_security_group.default.id]
4949

5050
# VPC endpoint for SSMMESSAGES
5151
enable_ssmmessages_endpoint = true
@@ -77,7 +77,20 @@ module "vpc" {
7777
kms_endpoint_private_dns_enabled = true
7878
kms_endpoint_security_group_ids = [data.aws_security_group.default.id]
7979

80-
# kms_endpoint_subnet_ids = ["..."]
80+
# VPC endpoint for ECS
81+
enable_ecs_endpoint = true
82+
ecs_endpoint_private_dns_enabled = true
83+
ecs_endpoint_security_group_ids = [data.aws_security_group.default.id]
84+
85+
# VPC endpoint for ECS telemetry
86+
enable_ecs_telemetry_endpoint = true
87+
ecs_telemetry_endpoint_private_dns_enabled = true
88+
ecs_telemetry_endpoint_security_group_ids = [data.aws_security_group.default.id]
89+
90+
# VPC endpoint for SQS
91+
enable_sqs_endpoint = true
92+
sqs_endpoint_private_dns_enabled = true
93+
sqs_endpoint_security_group_ids = [data.aws_security_group.default.id]
8194

8295
tags = {
8396
Owner = "user"

examples/complete-vpc/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/issue-108-route-already-exists/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/issue-224-vpcendpoint-apigw/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/issue-44-asymmetric-private-subnets/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/issue-46-no-private-subnets/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/manage-default-vpc/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/network-acls/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/secondary-cidr-blocks/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/simple-vpc/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/test_fixture/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/vpc-separate-private-route-tables/versions.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

main.tf

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
terraform {
2-
required_version = ">= 0.12"
3-
}
4-
51
locals {
62
max_subnet_length = max(
73
length(var.private_subnets),
@@ -901,6 +897,27 @@ resource "aws_vpc_endpoint_route_table_association" "public_dynamodb" {
901897
route_table_id = aws_route_table.public[0].id
902898
}
903899

900+
#######################
901+
# VPC Endpoint for SQS
902+
#######################
903+
data "aws_vpc_endpoint_service" "sqs" {
904+
count = var.create_vpc && var.enable_sqs_endpoint ? 1 : 0
905+
906+
service = "sqs"
907+
}
908+
909+
resource "aws_vpc_endpoint" "sqs" {
910+
count = var.create_vpc && var.enable_sqs_endpoint ? 1 : 0
911+
912+
vpc_id = local.vpc_id
913+
service_name = data.aws_vpc_endpoint_service.sqs[0].service_name
914+
vpc_endpoint_type = "Interface"
915+
916+
security_group_ids = var.sqs_endpoint_security_group_ids
917+
subnet_ids = coalescelist(var.sqs_endpoint_subnet_ids, aws_subnet.private.*.id)
918+
private_dns_enabled = var.sqs_endpoint_private_dns_enabled
919+
}
920+
904921
#######################
905922
# VPC Endpoint for SSM
906923
#######################
@@ -1069,6 +1086,71 @@ resource "aws_vpc_endpoint" "kms" {
10691086
private_dns_enabled = var.kms_endpoint_private_dns_enabled
10701087
}
10711088

1089+
#######################
1090+
# VPC Endpoint for ECS
1091+
#######################
1092+
data "aws_vpc_endpoint_service" "ecs" {
1093+
count = var.create_vpc && var.enable_ecs_endpoint ? 1 : 0
1094+
1095+
service = "ecs"
1096+
}
1097+
1098+
resource "aws_vpc_endpoint" "ecs" {
1099+
count = var.create_vpc && var.enable_ecs_endpoint ? 1 : 0
1100+
1101+
vpc_id = local.vpc_id
1102+
service_name = data.aws_vpc_endpoint_service.ecs[0].service_name
1103+
vpc_endpoint_type = "Interface"
1104+
1105+
security_group_ids = var.ecs_endpoint_security_group_ids
1106+
subnet_ids = coalescelist(var.ecs_endpoint_subnet_ids, aws_subnet.private.*.id)
1107+
private_dns_enabled = var.ecs_endpoint_private_dns_enabled
1108+
}
1109+
1110+
1111+
#######################
1112+
# VPC Endpoint for ECS Agent
1113+
#######################
1114+
data "aws_vpc_endpoint_service" "ecs_agent" {
1115+
count = var.create_vpc && var.enable_ecs_agent_endpoint ? 1 : 0
1116+
1117+
service = "ecs-agent"
1118+
}
1119+
1120+
resource "aws_vpc_endpoint" "ecs_agent" {
1121+
count = var.create_vpc && var.enable_ecs_agent_endpoint ? 1 : 0
1122+
1123+
vpc_id = local.vpc_id
1124+
service_name = data.aws_vpc_endpoint_service.ecs_agent[0].service_name
1125+
vpc_endpoint_type = "Interface"
1126+
1127+
security_group_ids = var.ecs_agent_endpoint_security_group_ids
1128+
subnet_ids = coalescelist(var.ecs_agent_endpoint_subnet_ids, aws_subnet.private.*.id)
1129+
private_dns_enabled = var.ecs_agent_endpoint_private_dns_enabled
1130+
}
1131+
1132+
1133+
#######################
1134+
# VPC Endpoint for ECS Telemetry
1135+
#######################
1136+
data "aws_vpc_endpoint_service" "ecs_telemetry" {
1137+
count = var.create_vpc && var.enable_ecs_telemetry_endpoint ? 1 : 0
1138+
1139+
service = "ecs-telemetry"
1140+
}
1141+
1142+
resource "aws_vpc_endpoint" "ecs_telemetry" {
1143+
count = var.create_vpc && var.enable_ecs_telemetry_endpoint ? 1 : 0
1144+
1145+
vpc_id = local.vpc_id
1146+
service_name = data.aws_vpc_endpoint_service.ecs_telemetry[0].service_name
1147+
vpc_endpoint_type = "Interface"
1148+
1149+
security_group_ids = var.ecs_telemetry_endpoint_security_group_ids
1150+
subnet_ids = coalescelist(var.ecs_telemetry_endpoint_subnet_ids, aws_subnet.private.*.id)
1151+
private_dns_enabled = var.ecs_telemetry_endpoint_private_dns_enabled
1152+
}
1153+
10721154
##########################
10731155
# Route table association
10741156
##########################

0 commit comments

Comments
 (0)