File tree Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,9 @@ module "test" {
30
30
| name_prefix | a name prefix used to tag vpc | ` string ` | true | yes |
31
31
| vpc_cidr | vpc cidr block | ` string ` | false | yes |
32
32
| public_subnets | public subnets map, availability zone map to cidr block | ` map ` | false | yes |
33
+ | extra_public_subnet_tags | extra tags to add to public subnet | ` map ` | false | false |
33
34
| private_subnets | private subnets map, availability zone map to cidr block | ` map ` | false | yes |
35
+ | extra_private_subnet_tags | extra tags to add to private subnet | ` map ` | false | false |
34
36
| natgateway | nat gateway list of availability zone to spread | ` list ` | false | yes |
35
37
36
38
## output
Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ module "test" {
8
8
b = " 10.17.2.0/23"
9
9
c = " 10.17.4.0/23"
10
10
}
11
+ extra_public_subnet_tags = {
12
+ " kubernetes.io/cluster/my-cluster" = " shared"
13
+ }
14
+ extra_private_subnet_tags = {
15
+ " kubernetes.io/cluster/my-cluster" = " shared"
16
+ }
11
17
private_subnets = {
12
18
a = " 10.17.6.0/23"
13
19
b = " 10.17.8.0/23"
@@ -16,7 +22,7 @@ module "test" {
16
22
}
17
23
18
24
output "public-subnet-ids" {
19
- value = [ for k ,v in module . test . public-subnet-ids : v ]
25
+ value = [for k , v in module . test . public-subnet-ids : v ]
20
26
}
21
27
output "a-private-subnet-id" {
22
28
value = module. test . private-subnet-ids [" a" ]
Original file line number Diff line number Diff line change @@ -53,9 +53,9 @@ resource "aws_subnet" "public-subnet" {
53
53
cidr_block = each. value
54
54
availability_zone = format (" %s%s" , data. aws_region . current . name , each. key )
55
55
map_public_ip_on_launch = " true"
56
- tags = {
56
+ tags = merge ( {
57
57
" Name" = format (" %s-public-%s" , var. name_prefix , each. key )
58
- }
58
+ }, var . extra_public_subnet_tags )
59
59
}
60
60
resource "aws_route_table_association" "public-rba" {
61
61
for_each = var. public_subnets
@@ -84,9 +84,9 @@ resource "aws_subnet" "private-subnet" {
84
84
cidr_block = each. value
85
85
availability_zone = format (" %s%s" , data. aws_region . current . name , each. key )
86
86
map_public_ip_on_launch = " false"
87
- tags = {
87
+ tags = merge ( {
88
88
" Name" = format (" %s-private-%s" , var. name_prefix , each. key )
89
- }
89
+ }, var . extra_private_subnet_tags )
90
90
}
91
91
92
92
resource "aws_route_table" "private-rt" {
Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ variable "public_subnets" {
16
16
}
17
17
description = " public subnets map, availability zone map to cidr block"
18
18
}
19
+
20
+ variable "extra_public_subnet_tags" {
21
+ default = {}
22
+ description = " extra tags to add to public subnet"
23
+ }
19
24
variable "private_subnets" {
20
25
default = {
21
26
a = " 10.240.12.0/22"
@@ -25,6 +30,11 @@ variable "private_subnets" {
25
30
description = " private subnets map, availability zone map to cidr block"
26
31
}
27
32
33
+ variable "extra_private_subnet_tags" {
34
+ default = {}
35
+ description = " extra tags to add to private subnet"
36
+ }
37
+
28
38
variable "natgateway" {
29
39
default = [" a" , " b" , " c" ]
30
40
description = " nat gateway list of availability zone to spread"
You can’t perform that action at this time.
0 commit comments