Skip to content

Commit ef0d14c

Browse files
authored
Merge pull request terraform-aws-modules#1 from terraform-aws-modules/master
test
2 parents 44bb589 + 8e2f50e commit ef0d14c

File tree

11 files changed

+301
-73
lines changed

11 files changed

+301
-73
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
repos:
22
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.7.4
3+
rev: v1.8.1
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_docs
77
- repo: git://github.com/pre-commit/pre-commit-hooks
8-
rev: v2.0.0
8+
rev: v2.1.0
99
hooks:
1010
- id: check-merge-conflict

README.md

Lines changed: 56 additions & 38 deletions
Large diffs are not rendered by default.

examples/complete-vpc/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Note that this example may create resources which can cost money (AWS Elastic IP
2828
| private\_subnets | List of IDs of private subnets |
2929
| public\_subnets | List of IDs of public subnets |
3030
| redshift\_subnets | List of IDs of redshift subnets |
31+
| vpc\_endpoint\_ssm\_dns\_entry | The DNS entries for the VPC Endpoint for SSM. |
32+
| vpc\_endpoint\_ssm\_id | The ID of VPC endpoint for SSM |
33+
| vpc\_endpoint\_ssm\_network\_interface\_ids | One or more network interfaces for the VPC Endpoint for SSM. |
3134
| vpc\_id | The ID of the VPC |
3235

3336
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/complete-vpc/main.tf

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ provider "aws" {
22
region = "eu-west-1"
33
}
44

5+
data "aws_security_group" "default" {
6+
name = "default"
7+
vpc_id = "${module.vpc.vpc_id}"
8+
}
9+
510
module "vpc" {
611
source = "../../"
712

@@ -19,18 +24,35 @@ module "vpc" {
1924

2025
create_database_subnet_group = false
2126

27+
enable_dns_hostnames = true
28+
enable_dns_support = true
29+
2230
enable_nat_gateway = true
2331
single_nat_gateway = true
2432

2533
enable_vpn_gateway = true
2634

27-
enable_s3_endpoint = true
28-
enable_dynamodb_endpoint = true
29-
3035
enable_dhcp_options = true
3136
dhcp_options_domain_name = "service.consul"
3237
dhcp_options_domain_name_servers = ["127.0.0.1", "10.10.0.2"]
3338

39+
# VPC endpoint for S3
40+
enable_s3_endpoint = true
41+
42+
# VPC endpoint for DynamoDB
43+
enable_dynamodb_endpoint = true
44+
45+
# VPC endpoint for SSM
46+
enable_ssm_endpoint = true
47+
ssm_endpoint_private_dns_enabled = true
48+
ssm_endpoint_security_group_ids = ["${data.aws_security_group.default.id}"]
49+
50+
// ssm_endpoint_subnet_ids = ["..."]
51+
52+
# VPC Endpoint for EC2
53+
enable_ec2_endpoint = true
54+
ec2_endpoint_private_dns_enabled = true
55+
ec2_endpoint_security_group_ids = ["${data.aws_security_group.default.id}"]
3456
tags = {
3557
Owner = "user"
3658
Environment = "staging"

examples/complete-vpc/outputs.tf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,37 @@ output "nat_public_ips" {
4040
description = "List of public Elastic IPs created for AWS NAT Gateway"
4141
value = ["${module.vpc.nat_public_ips}"]
4242
}
43+
44+
# VPC endpoints
45+
output "vpc_endpoint_ssm_id" {
46+
description = "The ID of VPC endpoint for SSM"
47+
value = "${module.vpc.vpc_endpoint_ssm_id}"
48+
}
49+
50+
output "vpc_endpoint_ssm_network_interface_ids" {
51+
description = "One or more network interfaces for the VPC Endpoint for SSM."
52+
value = ["${module.vpc.vpc_endpoint_ssm_network_interface_ids}"]
53+
}
54+
55+
output "vpc_endpoint_ssm_dns_entry" {
56+
description = "The DNS entries for the VPC Endpoint for SSM."
57+
value = ["${module.vpc.vpc_endpoint_ssm_dns_entry}"]
58+
}
59+
60+
//
61+
//# VPC endpoints
62+
//output "vpc_endpoint_ec2_id" {
63+
// description = "The ID of VPC endpoint for EC2"
64+
// value = "${module.vpc.vpc_endpoint_ec2_id}"
65+
//}
66+
//
67+
//output "vpc_endpoint_ec2_network_interface_ids" {
68+
// description = "One or more network interfaces for the VPC Endpoint for EC2."
69+
// value = ["${module.vpc.vpc_endpoint_ec2_network_interface_ids}"]
70+
//}
71+
//
72+
//output "vpc_endpoint_ec2_dns_entry" {
73+
// description = "The DNS entries for the VPC Endpoint for EC2."
74+
// value = ["${module.vpc.vpc_endpoint_ec2_dns_entry}"]
75+
//}
76+

examples/simple-vpc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP
2121

2222
| Name | Description |
2323
|------|-------------|
24+
| azs | A list of availability zones spefified as argument to this module |
2425
| nat\_public\_ips | List of public Elastic IPs created for AWS NAT Gateway |
2526
| private\_subnets | List of IDs of private subnets |
2627
| public\_subnets | List of IDs of public subnets |

examples/simple-vpc/outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ output "nat_public_ips" {
3131
description = "List of public Elastic IPs created for AWS NAT Gateway"
3232
value = ["${module.vpc.nat_public_ips}"]
3333
}
34+
35+
# AZs
36+
output "azs" {
37+
description = "A list of availability zones spefified as argument to this module"
38+
value = ["${module.vpc.azs}"]
39+
}

examples/test_fixture/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This will destroy any existing test resources, create the resources afresh, run
2525

2626
| Name | Description | Type | Default | Required |
2727
|------|-------------|:----:|:-----:|:-----:|
28-
| region | - | string | `eu-west-1` | no |
28+
| region | | string | `"eu-west-1"` | no |
2929

3030
## Outputs
3131

main.tf

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ resource "aws_route_table" "database" {
122122
}
123123

124124
resource "aws_route" "database_internet_gateway" {
125-
count = "${var.create_vpc && var.create_database_subnet_route_table && length(var.database_subnets) > 0 && var.create_database_internet_gateway_route ? 1 : 0}"
125+
count = "${var.create_vpc && var.create_database_subnet_route_table && length(var.database_subnets) > 0 && var.create_database_internet_gateway_route && !var.create_database_nat_gateway_route ? 1 : 0}"
126126

127127
route_table_id = "${aws_route_table.database.id}"
128128
destination_cidr_block = "0.0.0.0/0"
@@ -133,6 +133,17 @@ resource "aws_route" "database_internet_gateway" {
133133
}
134134
}
135135

136+
resource "aws_route" "database_nat_gateway" {
137+
count = "${var.create_vpc && var.create_database_subnet_route_table && length(var.database_subnets) > 0 && !var.create_database_internet_gateway_route && var.create_database_nat_gateway_route && var.enable_nat_gateway ? local.nat_gateway_count : 0}"
138+
route_table_id = "${element(aws_route_table.private.*.id, count.index)}"
139+
destination_cidr_block = "0.0.0.0/0"
140+
nat_gateway_id = "${element(aws_nat_gateway.this.*.id, count.index)}"
141+
142+
timeouts {
143+
create = "5m"
144+
}
145+
}
146+
136147
#################
137148
# Redshift routes
138149
#################
@@ -230,7 +241,7 @@ resource "aws_subnet" "redshift" {
230241
}
231242

232243
resource "aws_redshift_subnet_group" "redshift" {
233-
count = "${var.create_vpc && length(var.redshift_subnets) > 0 ? 1 : 0}"
244+
count = "${var.create_vpc && length(var.redshift_subnets) > 0 && var.create_redshift_subnet_group ? 1 : 0}"
234245

235246
name = "${lower(var.name)}"
236247
description = "Redshift subnet group for ${var.name}"
@@ -253,7 +264,7 @@ resource "aws_subnet" "elasticache" {
253264
}
254265

255266
resource "aws_elasticache_subnet_group" "elasticache" {
256-
count = "${var.create_vpc && length(var.elasticache_subnets) > 0 ? 1 : 0}"
267+
count = "${var.create_vpc && length(var.elasticache_subnets) > 0 && var.create_elasticache_subnet_group ? 1 : 0}"
257268

258269
name = "${var.name}"
259270
description = "ElastiCache subnet group for ${var.name}"
@@ -393,6 +404,48 @@ resource "aws_vpc_endpoint_route_table_association" "public_dynamodb" {
393404
route_table_id = "${aws_route_table.public.id}"
394405
}
395406

407+
######################
408+
# VPC Endpoint for SSM
409+
######################
410+
data "aws_vpc_endpoint_service" "ssm" {
411+
count = "${var.create_vpc && var.enable_ssm_endpoint ? 1 : 0}"
412+
413+
service = "ssm"
414+
}
415+
416+
resource "aws_vpc_endpoint" "ssm" {
417+
count = "${var.create_vpc && var.enable_ssm_endpoint ? 1 : 0}"
418+
419+
vpc_id = "${local.vpc_id}"
420+
service_name = "${data.aws_vpc_endpoint_service.ssm.service_name}"
421+
vpc_endpoint_type = "Interface"
422+
423+
security_group_ids = ["${var.ssm_endpoint_security_group_ids}"]
424+
subnet_ids = ["${coalescelist(var.ssm_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
425+
private_dns_enabled = "${var.ssm_endpoint_private_dns_enabled}"
426+
}
427+
428+
######################
429+
# VPC Endpoint for EC2
430+
######################
431+
data "aws_vpc_endpoint_service" "ec2" {
432+
count = "${var.create_vpc && var.enable_ec2_endpoint ? 1 : 0}"
433+
434+
service = "ec2"
435+
}
436+
437+
resource "aws_vpc_endpoint" "ec2" {
438+
count = "${var.create_vpc && var.enable_ec2_endpoint ? 1 : 0}"
439+
440+
vpc_id = "${local.vpc_id}"
441+
service_name = "${data.aws_vpc_endpoint_service.ec2.service_name}"
442+
vpc_endpoint_type = "Interface"
443+
444+
security_group_ids = ["${var.ec2_endpoint_security_group_ids}"]
445+
subnet_ids = ["${coalescelist(var.ec2_endpoint_subnet_ids, aws_subnet.private.*.id)}"]
446+
private_dns_enabled = "${var.ec2_endpoint_private_dns_enabled}"
447+
}
448+
396449
##########################
397450
# Route table association
398451
##########################

outputs.tf

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -193,31 +193,11 @@ output "igw_id" {
193193
value = "${element(concat(aws_internet_gateway.this.*.id, list("")), 0)}"
194194
}
195195

196-
output "vpc_endpoint_s3_id" {
197-
description = "The ID of VPC endpoint for S3"
198-
value = "${element(concat(aws_vpc_endpoint.s3.*.id, list("")), 0)}"
199-
}
200-
201-
output "vpc_endpoint_s3_pl_id" {
202-
description = "The prefix list for the S3 VPC endpoint."
203-
value = "${element(concat(aws_vpc_endpoint.s3.*.prefix_list_id, list("")), 0)}"
204-
}
205-
206-
output "vpc_endpoint_dynamodb_id" {
207-
description = "The ID of VPC endpoint for DynamoDB"
208-
value = "${element(concat(aws_vpc_endpoint.dynamodb.*.id, list("")), 0)}"
209-
}
210-
211196
output "vgw_id" {
212197
description = "The ID of the VPN Gateway"
213198
value = "${element(concat(aws_vpn_gateway.this.*.id, aws_vpn_gateway_attachment.this.*.vpn_gateway_id, list("")), 0)}"
214199
}
215200

216-
output "vpc_endpoint_dynamodb_pl_id" {
217-
description = "The prefix list for the DynamoDB VPC endpoint."
218-
value = "${element(concat(aws_vpc_endpoint.dynamodb.*.prefix_list_id, list("")), 0)}"
219-
}
220-
221201
output "default_vpc_id" {
222202
description = "The ID of the VPC"
223203
value = "${element(concat(aws_default_vpc.this.*.id, list("")), 0)}"
@@ -278,3 +258,59 @@ output "default_vpc_main_route_table_id" {
278258
// value = "${element(concat(aws_default_vpc.this.*.ipv6_cidr_block, list("")), 0)}"
279259
//}
280260

261+
# VPC Endpoints
262+
output "vpc_endpoint_s3_id" {
263+
description = "The ID of VPC endpoint for S3"
264+
value = "${element(concat(aws_vpc_endpoint.s3.*.id, list("")), 0)}"
265+
}
266+
267+
output "vpc_endpoint_s3_pl_id" {
268+
description = "The prefix list for the S3 VPC endpoint."
269+
value = "${element(concat(aws_vpc_endpoint.s3.*.prefix_list_id, list("")), 0)}"
270+
}
271+
272+
output "vpc_endpoint_dynamodb_id" {
273+
description = "The ID of VPC endpoint for DynamoDB"
274+
value = "${element(concat(aws_vpc_endpoint.dynamodb.*.id, list("")), 0)}"
275+
}
276+
277+
output "vpc_endpoint_dynamodb_pl_id" {
278+
description = "The prefix list for the DynamoDB VPC endpoint."
279+
value = "${element(concat(aws_vpc_endpoint.dynamodb.*.prefix_list_id, list("")), 0)}"
280+
}
281+
282+
output "vpc_endpoint_ssm_id" {
283+
description = "The ID of VPC endpoint for SSM"
284+
value = "${element(concat(aws_vpc_endpoint.ssm.*.id, list("")), 0)}"
285+
}
286+
287+
output "vpc_endpoint_ssm_network_interface_ids" {
288+
description = "One or more network interfaces for the VPC Endpoint for SSM."
289+
value = "${flatten(aws_vpc_endpoint.ssm.*.network_interface_ids)}"
290+
}
291+
292+
output "vpc_endpoint_ssm_dns_entry" {
293+
description = "The DNS entries for the VPC Endpoint for SSM."
294+
value = "${flatten(aws_vpc_endpoint.ssm.*.dns_entry)}"
295+
}
296+
297+
output "vpc_endpoint_ec2_id" {
298+
description = "The ID of VPC endpoint for EC2"
299+
value = "${element(concat(aws_vpc_endpoint.ec2.*.id, list("")), 0)}"
300+
}
301+
302+
output "vpc_endpoint_ec2_network_interface_ids" {
303+
description = "One or more network interfaces for the VPC Endpoint for EC2"
304+
value = "${flatten(aws_vpc_endpoint.ec2.*.network_interface_ids)}"
305+
}
306+
307+
output "vpc_endpoint_ec2_dns_entry" {
308+
description = "The DNS entries for the VPC Endpoint for EC2."
309+
value = "${flatten(aws_vpc_endpoint.ec2.*.dns_entry)}"
310+
}
311+
312+
# Static values (arguments)
313+
output "azs" {
314+
description = "A list of availability zones specified as argument to this module"
315+
value = "${var.azs}"
316+
}

0 commit comments

Comments
 (0)