Skip to content

Commit

Permalink
Session 6 Goal 1 | Refactor local.tf, add version to module vpc
Browse files Browse the repository at this point in the history
  • Loading branch information
krishanuc1001 committed Aug 25, 2024
1 parent c668dc1 commit fe4cad0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 7 additions & 8 deletions local.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
locals {
vpc_id = module.vpc.vpc_id
azs = slice(data.aws_availability_zones.available.names, 0, 2)
azs = slice(data.aws_availability_zones.available.names, 0, 2)

number_of_public_subnets = var.public_subnets
number_of_private_subnets = var.private_subnets
number_of_secure_subnets = var.secure_subnets
number_of_route_tables_association_public_subnet = var.public_subnets
number_of_public_subnets = var.public_subnets
number_of_private_subnets = var.private_subnets
number_of_secure_subnets = var.secure_subnets

public_subnet_cidrs = [for i in range(var.public_subnets) : cidrsubnet(var.vpc_cidr, 3, i + 1)]
private_subnet_cidrs = [for i in range(var.private_subnets) : cidrsubnet(var.vpc_cidr, 3, i + 3)]
secure_subnet_cidrs = [for i in range(var.secure_subnets) : cidrsubnet(var.vpc_cidr, 3, i + 5)]
public_subnet_cidrs = [for i in range(number_of_public_subnets) : cidrsubnet(var.vpc_cidr, 3, i + 1)]
private_subnet_cidrs = [for i in range(number_of_private_subnets) : cidrsubnet(var.vpc_cidr, 3, i + 3)]
secure_subnet_cidrs = [for i in range(number_of_secure_subnets) : cidrsubnet(var.vpc_cidr, 3, i + 5)]
}
1 change: 1 addition & 0 deletions network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ data "aws_availability_zones" "available" {}

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.13.0"

name = format("%s-vpc", var.prefix)
cidr = var.vpc_cidr
Expand Down

0 comments on commit fe4cad0

Please sign in to comment.