Skip to content

Commit f500e6b

Browse files
author
Richard Nghiem
committed
route_table_names
1 parent 961c9b5 commit f500e6b

File tree

2 files changed

+55
-7
lines changed

2 files changed

+55
-7
lines changed

main.tf

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,13 @@ resource "aws_route_table" "public" {
165165

166166
tags = merge(
167167
{
168-
"Name" = var.create_multiple_public_route_tables ? format(
169-
"${var.name}-${var.public_subnet_suffix}-%s",
170-
element(var.azs, count.index),
171-
) : "${var.name}-${var.public_subnet_suffix}"
168+
Name = try(
169+
var.public_route_table_names[count.index],
170+
var.create_multiple_public_route_tables ? format(
171+
"${var.name}-${var.public_subnet_suffix}-%s",
172+
element(var.azs, count.index),
173+
) : "${var.name}-${var.public_subnet_suffix}"
174+
)
172175
},
173176
var.tags,
174177
var.public_route_table_tags,
@@ -297,9 +300,12 @@ resource "aws_route_table" "private" {
297300

298301
tags = merge(
299302
{
300-
"Name" = var.single_nat_gateway ? "${var.name}-${var.private_subnet_suffix}" : format(
301-
"${var.name}-${var.private_subnet_suffix}-%s",
302-
element(var.azs, count.index),
303+
Name = try(
304+
var.private_route_table_names[count.index],
305+
var.single_nat_gateway ? "${var.name}-${var.private_subnet_suffix}" : format(
306+
"${var.name}-${var.private_subnet_suffix}-%s",
307+
element(var.azs, count.index),
308+
)
303309
)
304310
},
305311
var.tags,

variables.tf

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ variable "public_subnet_private_dns_hostname_type_on_launch" {
244244
default = null
245245
}
246246

247+
variable "public_route_table_names" {
248+
description = "Explicit values to use in the Name tag on public route tables. If empty, Name tags are generated"
249+
type = list(string)
250+
default = []
251+
}
252+
247253
variable "public_subnet_names" {
248254
description = "Explicit values to use in the Name tag on public subnets. If empty, Name tags are generated"
249255
type = list(string)
@@ -372,6 +378,12 @@ variable "private_subnet_private_dns_hostname_type_on_launch" {
372378
default = null
373379
}
374380

381+
variable "private_route_table_names" {
382+
description = "Explicit values to use in the Name tag on private route tables. If empty, Name tags are generated"
383+
type = list(string)
384+
default = []
385+
}
386+
375387
variable "private_subnet_names" {
376388
description = "Explicit values to use in the Name tag on private subnets. If empty, Name tags are generated"
377389
type = list(string)
@@ -506,6 +518,12 @@ variable "database_subnet_private_dns_hostname_type_on_launch" {
506518
default = null
507519
}
508520

521+
variable "database_route_table_names" {
522+
description = "Explicit values to use in the Name tag on database route tables. If empty, Name tags are generated"
523+
type = list(string)
524+
default = []
525+
}
526+
509527
variable "database_subnet_names" {
510528
description = "Explicit values to use in the Name tag on database subnets. If empty, Name tags are generated"
511529
type = list(string)
@@ -664,6 +682,12 @@ variable "redshift_subnet_private_dns_hostname_type_on_launch" {
664682
default = null
665683
}
666684

685+
variable "redshift_route_table_names" {
686+
description = "Explicit values to use in the Name tag on redshift route tables. If empty, Name tags are generated"
687+
type = list(string)
688+
default = []
689+
}
690+
667691
variable "redshift_subnet_names" {
668692
description = "Explicit values to use in the Name tag on redshift subnets. If empty, Name tags are generated"
669693
type = list(string)
@@ -816,6 +840,12 @@ variable "elasticache_subnet_private_dns_hostname_type_on_launch" {
816840
default = null
817841
}
818842

843+
variable "elasticache_route_table_names" {
844+
description = "Explicit values to use in the Name tag on public route tables. If empty, Name tags are generated"
845+
type = list(string)
846+
default = []
847+
}
848+
819849
variable "elasticache_subnet_names" {
820850
description = "Explicit values to use in the Name tag on elasticache subnets. If empty, Name tags are generated"
821851
type = list(string)
@@ -968,6 +998,12 @@ variable "intra_subnet_private_dns_hostname_type_on_launch" {
968998
default = null
969999
}
9701000

1001+
variable "intra_route_table_names" {
1002+
description = "Explicit values to use in the Name tag on intra route tables. If empty, Name tags are generated"
1003+
type = list(string)
1004+
default = []
1005+
}
1006+
9711007
variable "intra_subnet_names" {
9721008
description = "Explicit values to use in the Name tag on intra subnets. If empty, Name tags are generated"
9731009
type = list(string)
@@ -1114,6 +1150,12 @@ variable "outpost_subnet_private_dns_hostname_type_on_launch" {
11141150
default = null
11151151
}
11161152

1153+
variable "outpost_route_table_names" {
1154+
description = "Explicit values to use in the Name tag on outpost route tables. If empty, Name tags are generated"
1155+
type = list(string)
1156+
default = []
1157+
}
1158+
11171159
variable "outpost_subnet_names" {
11181160
description = "Explicit values to use in the Name tag on outpost subnets. If empty, Name tags are generated"
11191161
type = list(string)

0 commit comments

Comments
 (0)