Skip to content

Commit

Permalink
expand vpc for #9
Browse files Browse the repository at this point in the history
  • Loading branch information
kunduso committed Aug 24, 2024
1 parent 3fe9dcc commit 00a2377
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions network.tf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}

}
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 00a2377

Please sign in to comment.