Skip to content

Commit

Permalink
#4 network stack
Browse files Browse the repository at this point in the history
  • Loading branch information
kunduso committed Aug 20, 2024
1 parent 0040338 commit 9c42756
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "aws_caller_identity" "current" {}

data "aws_availability_zones" "available" {}
31 changes: 31 additions & 0 deletions network.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

resource "aws_vpc" "this" {
#checkov:skip=CKV2_AWS_11: This is non prod and hence disabled.
cidr_block = var.vpc_cidr
enable_dns_hostnames = true
enable_dns_support = true
tags = {
"Name" = "${var.name}"
}
}
resource "aws_subnet" "db" {
count = length(var.subnet_cidr)
vpc_id = aws_vpc.this.id
cidr_block = var.subnet_cidr[count.index]
availability_zone = data.aws_availability_zones.available.names[count.index]
tags = {
"Name" = "${var.name}subnet-${count.index + 1}"
}
}
resource "aws_route_table" "this_rt" {
vpc_id = aws_vpc.this.id
tags = {
"Name" = "${var.name}-route-table"
}
}
resource "aws_route_table_association" "db" {
count = length(var.subnet_cidr)
subnet_id = element(aws_subnet.db.*.id, count.index)
route_table_id = aws_route_table.this_rt.id
}

0 comments on commit 9c42756

Please sign in to comment.