From 00a237761e85cd8ee857302c89082358912f47bc Mon Sep 17 00:00:00 2001 From: Sourav Kundu Date: Fri, 23 Aug 2024 22:07:57 -0500 Subject: [PATCH] expand vpc for #9 --- network.tf | 13 ++++++++----- variables.tf | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/network.tf b/network.tf index c77884a..335c408 100644 --- a/network.tf +++ b/network.tf @@ -1,4 +1,5 @@ +#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc resource "aws_vpc" "this" { #checkov:skip=CKV2_AWS_11: This is non prod and hence disabled. cidr_block = var.vpc_cidr @@ -8,24 +9,26 @@ resource "aws_vpc" "this" { "Name" = "${var.name}" } } +#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet resource "aws_subnet" "db" { - count = length(var.subnet_cidr) + count = length(var.subnet_cidr_db) vpc_id = aws_vpc.this.id - cidr_block = var.subnet_cidr[count.index] + cidr_block = var.subnet_cidr_db[count.index] availability_zone = data.aws_availability_zones.available.names[count.index] tags = { "Name" = "${var.name}subnet-${count.index + 1}" } } +#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table resource "aws_route_table" "this_rt" { vpc_id = aws_vpc.this.id tags = { "Name" = "${var.name}-route-table" } } +#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association resource "aws_route_table_association" "db" { - count = length(var.subnet_cidr) + count = length(var.subnet_cidr_db) subnet_id = element(aws_subnet.db.*.id, count.index) route_table_id = aws_route_table.this_rt.id -} - +} \ No newline at end of file diff --git a/variables.tf b/variables.tf index b61ca5d..382e484 100644 --- a/variables.tf +++ b/variables.tf @@ -26,9 +26,9 @@ variable "name" { variable "vpc_cidr" { description = "The CIDR of the VPC." type = string - default = "15.25.15.0/27" + default = "15.25.15.0/26" } -variable "subnet_cidr" { +variable "subnet_cidr_db" { description = "The CIDR blocks for the subnets." type = list(any) default = ["15.25.15.0/28", "15.25.15.16/28"]