diff --git a/infra/blockchain/main.tf b/infra/blockchain/main.tf new file mode 100644 index 0000000..f63cffa --- /dev/null +++ b/infra/blockchain/main.tf @@ -0,0 +1,7 @@ +module "vpc" { + source = "./vpc" + + env = var.env + region = var.region + name = var.name +} diff --git a/infra/blockchain/variables.tf b/infra/blockchain/variables.tf new file mode 100644 index 0000000..5ff35cd --- /dev/null +++ b/infra/blockchain/variables.tf @@ -0,0 +1,14 @@ +variable "region" { + description = "The region where the resources will be created" + type = string +} + +variable "env" { + description = "The environment name" + type = string +} + +variable "name" { + description = "The name of the VPC" + type = string +} diff --git a/infra/blockchain/vpc/main.tf b/infra/blockchain/vpc/main.tf new file mode 100644 index 0000000..81fe105 --- /dev/null +++ b/infra/blockchain/vpc/main.tf @@ -0,0 +1,30 @@ +# Filter out local zones not currently supported +# with managed node groups +data "aws_availability_zones" "available" { + filter { + name = "opt-in-status" + values = ["opt-in-not-required"] + } +} + +module "iac-max-vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "5.0.0" + + name = "iac-max-vpc" + + cidr = "10.0.0.0/16" + azs = [data.aws_availability_zones.available.names[0]] + + public_subnets = ["10.0.1.0/24"] + + enable_nat_gateway = true + single_nat_gateway = true + enable_dns_hostnames = true + + tags = { + Terraform = "true" + Environment = var.env + } + +} diff --git a/infra/blockchain/vpc/outputs.tf b/infra/blockchain/vpc/outputs.tf new file mode 100644 index 0000000..5266731 --- /dev/null +++ b/infra/blockchain/vpc/outputs.tf @@ -0,0 +1,14 @@ +output "vpc_id" { + value = module.vpc.vpc_id + description = "The ID of the VPC created." +} + +output "public_subnet_ids" { + value = module.vpc.public_subnet_ids + description = "List of IDs of public subnets." +} + +output "private_subnet_ids" { + value = module.vpc.private_subnet_ids + description = "List of IDs of private subnets." +} diff --git a/infra/blockchain/vpc/variables.tf b/infra/blockchain/vpc/variables.tf new file mode 100644 index 0000000..3a5f849 --- /dev/null +++ b/infra/blockchain/vpc/variables.tf @@ -0,0 +1,13 @@ +variable "region" { + description = "Region where the VPC will be created" + type = string +} +variable "name" { + description = "Name of the VPC" + type = string +} + +variable "env" { + description = "Environment" + type = string +} diff --git a/infra/vpc/main.tf b/infra/vpc/main.tf index f77a2e3..bdcf892 100644 --- a/infra/vpc/main.tf +++ b/infra/vpc/main.tf @@ -1,3 +1,7 @@ +provider "aws" { + region = var.region +} + # Filter out local zones not currently supported # with managed node groups data "aws_availability_zones" "available" { @@ -14,13 +18,17 @@ module "iac-max-vpc" { name = "iac-max-vpc" cidr = "10.0.0.0/16" - azs = slice(data.aws_availability_zones.available.names, 0, 3) + azs = [data.aws_availability_zones.available.names[0]] - private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] - public_subnets = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"] + public_subnets = ["10.0.1.0/24"] enable_nat_gateway = true single_nat_gateway = true enable_dns_hostnames = true + tags = { + Terraform = "true" + Environment = var.env + } + } diff --git a/infra/vpc/variables.tf b/infra/vpc/variables.tf index 50a8d5b..3a5f849 100644 --- a/infra/vpc/variables.tf +++ b/infra/vpc/variables.tf @@ -1,34 +1,13 @@ +variable "region" { + description = "Region where the VPC will be created" + type = string +} variable "name" { description = "Name of the VPC" type = string } -variable "cidr" { - description = "CIDR block for the VPC" +variable "env" { + description = "Environment" type = string } - -variable "azs" { - description = "Availability Zones to use for the subnets" - type = list(string) -} - -variable "private_subnets" { - description = "List of private subnet CIDRs" - type = list(string) -} - -variable "public_subnets" { - description = "List of public subnet CIDRs" - type = list(string) -} - -variable "enable_nat_gateway" { - description = "Should be true if NAT gateway should be created" - type = bool -} - -variable "enable_vpn_gateway" { - description = "Should be true if VPN gateway should be created" - type = bool -}