File tree Expand file tree Collapse file tree 9 files changed +157
-26
lines changed
issue-44-asymmetric-private-subnets
issue-46-no-private-subnets Expand file tree Collapse file tree 9 files changed +157
-26
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ Examples
91
91
92
92
* [ Simple VPC] ( https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/simple-vpc )
93
93
* [ Complete VPC] ( https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/complete-vpc )
94
+ * Few tests and edge cases examples: [ #46 ] ( https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/issue-46-no-private-subnets ) , [ #44 ] ( https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/issue-44-asymmetric-private-subnets )
94
95
95
96
Authors
96
97
-------
Original file line number Diff line number Diff line change @@ -29,28 +29,3 @@ module "vpc" {
29
29
Name = " complete"
30
30
}
31
31
}
32
-
33
- # This example creates resources which are not present in all AZs.
34
- # This should be seldomly needed from architectural point of view,
35
- # and it can also lead this module to some edge cases.
36
- module "not_symmetrical_vpc" {
37
- source = " ../../"
38
-
39
- name = " not-symmetrical-example"
40
-
41
- cidr = " 10.0.0.0/16"
42
-
43
- azs = [" eu-west-1a" , " eu-west-1b" , " eu-west-1c" ]
44
- private_subnets = [" 10.0.1.0/24" ]
45
- public_subnets = [" 10.0.101.0/24" , " 10.0.102.0/24" ]
46
- database_subnets = [" 10.0.21.0/24" , " 10.0.22.0/24" , " 10.0.23.0/24" ]
47
-
48
- create_database_subnet_group = true
49
- enable_nat_gateway = true
50
-
51
- tags = {
52
- Terraform = " true"
53
- Environment = " dev"
54
- Name = " not-symmetrical"
55
- }
56
- }
Original file line number Diff line number Diff line change
1
+ Issue 44 - VPC
2
+ ==============
3
+
4
+ Configuration in this directory creates set of VPC resources to cover issues reported on GitHub:
5
+
6
+ * https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/44
7
+
8
+ Usage
9
+ =====
10
+
11
+ To run this example you need to execute:
12
+
13
+ ``` bash
14
+ $ terraform init
15
+ $ terraform plan
16
+ $ terraform apply
17
+ ```
18
+
19
+ Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run ` terraform destroy ` when you don't need these resources.
Original file line number Diff line number Diff line change
1
+ # List of AZs and private subnets are not of equal length
2
+ #
3
+ # This example creates resources which are not present in all AZs.
4
+ # This should be seldomly needed from architectural point of view,
5
+ # and it can also lead this module to some edge cases.
6
+ #
7
+ # Github issue: https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/44
8
+ module "vpc" {
9
+ source = " ../../"
10
+
11
+ name = " asymmetrical"
12
+
13
+ cidr = " 10.0.0.0/16"
14
+
15
+ azs = [" eu-west-1a" , " eu-west-1b" , " eu-west-1c" ]
16
+ private_subnets = [" 10.0.1.0/24" ]
17
+ public_subnets = [" 10.0.101.0/24" , " 10.0.102.0/24" ]
18
+ database_subnets = [" 10.0.21.0/24" , " 10.0.22.0/24" , " 10.0.23.0/24" ]
19
+
20
+ create_database_subnet_group = true
21
+ enable_nat_gateway = true
22
+
23
+ tags = {
24
+ Issue = " 44"
25
+ Name = " asymmetrical"
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ # VPC
2
+ output "vpc_id" {
3
+ description = " The ID of the VPC"
4
+ value = " ${ module . vpc . vpc_id } "
5
+ }
6
+
7
+ # Subnets
8
+ output "private_subnets" {
9
+ description = " List of IDs of private subnets"
10
+ value = [" ${ module . vpc . private_subnets } " ]
11
+ }
12
+
13
+ output "public_subnets" {
14
+ description = " List of IDs of public subnets"
15
+ value = [" ${ module . vpc . public_subnets } " ]
16
+ }
17
+
18
+ output "database_subnets" {
19
+ description = " List of IDs of database subnets"
20
+ value = [" ${ module . vpc . database_subnets } " ]
21
+ }
22
+
23
+ output "elasticache_subnets" {
24
+ description = " List of IDs of elasticache subnets"
25
+ value = [" ${ module . vpc . elasticache_subnets } " ]
26
+ }
27
+
28
+ # NAT gateways
29
+ output "nat_public_ips" {
30
+ description = " List of public Elastic IPs created for AWS NAT Gateway"
31
+ value = [" ${ module . vpc . nat_public_ips } " ]
32
+ }
Original file line number Diff line number Diff line change
1
+ Issue 46 - VPC
2
+ ==============
3
+
4
+ Configuration in this directory creates set of VPC resources to cover issues reported on GitHub:
5
+
6
+ * https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/46
7
+
8
+ Usage
9
+ =====
10
+
11
+ To run this example you need to execute:
12
+
13
+ ``` bash
14
+ $ terraform init
15
+ $ terraform plan
16
+ $ terraform apply
17
+ ```
18
+
19
+ Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run ` terraform destroy ` when you don't need these resources.
Original file line number Diff line number Diff line change
1
+ # There are no private subnets in this VPC setup.
2
+ #
3
+ # Github issue: https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/46
4
+ module "vpc" {
5
+ source = " ../../"
6
+
7
+ name = " no-private-subnets"
8
+
9
+ cidr = " 10.0.0.0/16"
10
+
11
+ azs = [" eu-west-1a" , " eu-west-1b" , " eu-west-1c" ]
12
+ public_subnets = [" 10.0.0.0/22" , " 10.0.4.0/22" , " 10.0.8.0/22" ]
13
+ private_subnets = []
14
+ database_subnets = [" 10.0.128.0/24" , " 10.0.129.0/24" ]
15
+ elasticache_subnets = [" 10.0.131.0/24" , " 10.0.132.0/24" , " 10.0.133.0/24" ]
16
+
17
+ enable_dns_support = true
18
+ enable_dns_hostnames = true
19
+ enable_nat_gateway = false
20
+
21
+ tags = {
22
+ Issue = " 46"
23
+ Name = " no-private-subnets"
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ # VPC
2
+ output "vpc_id" {
3
+ description = " The ID of the VPC"
4
+ value = " ${ module . vpc . vpc_id } "
5
+ }
6
+
7
+ # Subnets
8
+ output "private_subnets" {
9
+ description = " List of IDs of private subnets"
10
+ value = [" ${ module . vpc . private_subnets } " ]
11
+ }
12
+
13
+ output "public_subnets" {
14
+ description = " List of IDs of public subnets"
15
+ value = [" ${ module . vpc . public_subnets } " ]
16
+ }
17
+
18
+ output "database_subnets" {
19
+ description = " List of IDs of database subnets"
20
+ value = [" ${ module . vpc . database_subnets } " ]
21
+ }
22
+
23
+ output "elasticache_subnets" {
24
+ description = " List of IDs of elasticache subnets"
25
+ value = [" ${ module . vpc . elasticache_subnets } " ]
26
+ }
27
+
28
+ # NAT gateways
29
+ output "nat_public_ips" {
30
+ description = " List of public Elastic IPs created for AWS NAT Gateway"
31
+ value = [" ${ module . vpc . nat_public_ips } " ]
32
+ }
Original file line number Diff line number Diff line change @@ -72,9 +72,10 @@ resource "aws_route" "public_internet_gateway" {
72
72
73
73
# ################
74
74
# Private routes
75
+ # There are so many route-tables as the largest amount of subnets of each type (really?)
75
76
# ################
76
77
resource "aws_route_table" "private" {
77
- count = " ${ length (var. private_subnets )} "
78
+ count = " ${ max ( length (var. private_subnets ), length (var . elasticache_subnets ), length (var . database_subnets ) )} "
78
79
79
80
vpc_id = " ${ aws_vpc . this . id } "
80
81
propagating_vgws = [" ${ var . private_propagating_vgws } " ]
You can’t perform that action at this time.
0 commit comments