Skip to content

Commit

Permalink
Merge pull request #2 from lsportsltd/lsports-1.0.1
Browse files Browse the repository at this point in the history
Add option to send cidrs as list instead using cidrsubnet function
  • Loading branch information
liranse authored Mar 21, 2023
2 parents 7d31c0f + 6960467 commit c9697ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion private.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ resource "aws_subnet" "private" {

vpc_id = var.vpc_id
availability_zone = each.key
cidr_block = cidrsubnet(var.cidr_block, ceil(log(var.max_subnets, 2)), each.value)
cidr_block = (length(var.subnet_cidr_block_list) == 0 ?
cidrsubnet(var.cidr_block, ceil(log(var.max_subnets, 2)), each.value) :
var.subnet_cidr_block_list[each.value])

tags = merge(
module.private_label.tags,
Expand Down
4 changes: 3 additions & 1 deletion public.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ resource "aws_subnet" "public" {

vpc_id = var.vpc_id
availability_zone = each.key
cidr_block = cidrsubnet(var.cidr_block, ceil(log(var.max_subnets, 2)), each.value)
cidr_block = (length(var.subnet_cidr_block_list) == 0 ?
cidrsubnet(var.cidr_block, ceil(log(var.max_subnets, 2)), each.value) :
var.subnet_cidr_block_list[each.value])
ipv6_cidr_block = local.public_ipv6_enabled ? cidrsubnet(var.ipv6_cidr_block, (
local.public_ipv6_target_mask - tonumber(split("/", var.ipv6_cidr_block)[1])
), each.value) : null
Expand Down
4 changes: 4 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,8 @@ variable "ipv6_cidr_block" {
}

variable "is_nat" {
}

variable "subnet_cidr_block_list" {
default = []
}

0 comments on commit c9697ec

Please sign in to comment.