Skip to content

Commit b311d37

Browse files
committed
updated module
1 parent 0e19470 commit b311d37

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ In this module, we have implemented the following CIS Compliance checks for VPC:
247247
| <a name="input_public_subnet_assign_ipv6_address_on_creation"></a> [public\_subnet\_assign\_ipv6\_address\_on\_creation](#input\_public\_subnet\_assign\_ipv6\_address\_on\_creation) | Assign IPv6 address on public subnet, must be disabled to change IPv6 CIDRs. This is the IPv6 equivalent of map\_public\_ip\_on\_launch | `bool` | `null` | no |
248248
| <a name="input_public_subnet_cidrs"></a> [public\_subnet\_cidrs](#input\_public\_subnet\_cidrs) | A list of public subnets CIDR to be created inside the VPC | `list(any)` | `[]` | no |
249249
| <a name="input_public_subnet_enabled"></a> [public\_subnet\_enabled](#input\_public\_subnet\_enabled) | Set true to enable public subnets | `bool` | `false` | no |
250-
| <a name="input_region"></a> [region](#input\_region) | The AWS region name | `string` | n/a | yes |
250+
| <a name="input_region"></a> [region](#input\_region) | The AWS region name | `string` | `null` | no |
251251
| <a name="input_secondary_cidr_blocks"></a> [secondary\_cidr\_blocks](#input\_secondary\_cidr\_blocks) | List of the secondary CIDR blocks which can be at most 5 | `list(string)` | `[]` | no |
252252
| <a name="input_secondry_cidr_enabled"></a> [secondry\_cidr\_enabled](#input\_secondry\_cidr\_enabled) | Whether enable secondary CIDR with VPC | `bool` | `false` | no |
253253
| <a name="input_vpc_cidr"></a> [vpc\_cidr](#input\_vpc\_cidr) | The CIDR block of the VPC | `string` | `"10.0.0.0/16"` | no |

main.tf

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
locals {
22
azs = length(var.availability_zones)
3-
region_name = var.region
43
public_subnets_native = var.public_subnet_enabled ? length(var.public_subnet_cidrs) > 0 ? var.public_subnet_cidrs : [for netnum in range(0, local.azs) : cidrsubnet(var.vpc_cidr, 8, netnum)] : []
54
secondary_public_subnets = var.public_subnet_enabled && var.secondry_cidr_enabled ? [
65
for cidr_block in var.secondary_cidr_blocks : [
@@ -67,8 +66,8 @@ module "vpc" {
6766
cidr = var.vpc_cidr # CIDR FOR VPC
6867
azs = [for n in range(0, local.azs) : data.aws_availability_zones.available.names[n]]
6968
use_ipam_pool = var.ipam_enabled ? true : false
70-
ipv4_ipam_pool_id = var.create_ipam_pool ? aws_vpc_ipam_pool.ipam_pool[0].id : var.ipam_pool_id
71-
ipv4_netmask_length = var.ipv4_netmask_length
69+
ipv4_ipam_pool_id = var.ipam_enabled && var.create_ipam_pool ? aws_vpc_ipam_pool.ipam_pool[0].id : null
70+
ipv4_netmask_length = var.ipam_enabled ? var.ipv4_netmask_length : null
7271
create_database_subnet_group = length(local.database_subnets) > 1 && var.enable_database_subnet_group ? true : false
7372
intra_subnets = local.intra_subnets
7473
public_subnets = local.public_subnets
@@ -190,7 +189,7 @@ module "vpn_server" {
190189
resource "aws_vpc_ipam" "ipam" {
191190
count = var.ipam_enabled && var.create_ipam_pool ? 1 : 0
192191
operating_regions {
193-
region_name = local.region_name
192+
region_name = var.region
194193
}
195194

196195

@@ -202,7 +201,7 @@ resource "aws_vpc_ipam_pool" "ipam_pool" {
202201
description = "IPv4 pool"
203202
address_family = "ipv4"
204203
ipam_scope_id = aws_vpc_ipam.ipam[0].private_default_scope_id
205-
locale = local.region_name
204+
locale = var.region
206205
allocation_default_netmask_length = 16
207206

208207

@@ -213,25 +212,3 @@ resource "aws_vpc_ipam_pool_cidr" "ipam_pool_cidr" {
213212
ipam_pool_id = var.create_ipam_pool ? aws_vpc_ipam_pool.ipam_pool[0].id : var.ipam_pool_id
214213
cidr = var.create_ipam_pool ? var.vpc_cidr : var.existing_ipam_managed_cidr
215214
}
216-
217-
# resource "aws_vpc_ipam_preview_next_cidr" "this" {
218-
# ipam_pool_id = aws_vpc_ipam_pool.this.id
219-
220-
# depends_on = [
221-
# aws_vpc_ipam_pool_cidr.this
222-
# ]
223-
# }
224-
225-
# IPv6
226-
# resource "aws_vpc_ipam_pool" "ipv6" {
227-
# count =
228-
# description = "IPv6 pool"
229-
# address_family = "ipv6"
230-
# ipam_scope_id = aws_vpc_ipam.this.public_default_scope_id
231-
# locale = var.region
232-
# allocation_default_netmask_length = 56
233-
# publicly_advertisable = false
234-
# aws_service = "ec2"
235-
236-
#
237-
# }

variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ variable "ipv4_netmask_length" {
255255
variable "region" {
256256
description = "The AWS region name"
257257
type = string
258+
default = null
258259
}
259260

260261
variable "existing_ipam_managed_cidr" {

0 commit comments

Comments
 (0)