Skip to content

Commit 427effe

Browse files
authored
Merge pull request #141 from tablexi/va-support-blacklisted_names-for-subnets
Support blacklisted_names in //aws/vpc/subnets
2 parents 44180f1 + 2f1d22c commit 427effe

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

aws/vpc/subnets/main.tf

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,12 @@
11
# Find the available availability zones
22
data "aws_availability_zones" "available" {
3+
blacklisted_names = var.blacklisted_names
34
}
45

56
data "aws_vpc" "current" {
67
id = var.vpc_id
78
}
89

9-
locals {
10-
default_az_to_netnum = {
11-
a = 1
12-
b = 2
13-
c = 3
14-
d = 4
15-
e = 5
16-
f = 6
17-
}
18-
}
19-
20-
data "template_file" "az_to_netnum" {
21-
count = length(data.aws_availability_zones.available.names)
22-
template = "$${netnum}"
23-
24-
vars = {
25-
netnum = local.default_az_to_netnum[substr(
26-
element(data.aws_availability_zones.available.names, count.index),
27-
-1,
28-
1,
29-
)]
30-
}
31-
}
32-
3310
resource "aws_route_table" "mod" {
3411
tags = var.tags
3512
vpc_id = var.vpc_id
@@ -48,7 +25,7 @@ resource "aws_subnet" "mod" {
4825
cidr_block = cidrsubnet(
4926
data.aws_vpc.current.cidr_block,
5027
var.newbits,
51-
var.netnum_offset + element(data.template_file.az_to_netnum[*].rendered, count.index),
28+
var.netnum_offset + count.index + 1,
5229
)
5330
map_public_ip_on_launch = var.public
5431
tags = var.tags

aws/vpc/subnets/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ variable "netnum_offset" {
2121
description = "Offset the subnets netnum by a specific amount."
2222
}
2323

24+
variable "blacklisted_names" {
25+
default = []
26+
description = "(Optional) List of blacklisted Availability Zone names."
27+
}
28+
2429
variable "tags" {
2530
description = "(Optional) A mapping of tags to assign to the resources"
2631
type = map(string)

0 commit comments

Comments
 (0)