Skip to content

Commit

Permalink
[feature] add blockchain module
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyBoWu committed May 20, 2024
1 parent 6101fd7 commit 9887cd4
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 30 deletions.
7 changes: 7 additions & 0 deletions infra/blockchain/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "vpc" {
source = "./vpc"

env = var.env
region = var.region
name = var.name
}
14 changes: 14 additions & 0 deletions infra/blockchain/variables.tf
Original file line number Diff line number Diff line change
@@ -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
}
30 changes: 30 additions & 0 deletions infra/blockchain/vpc/main.tf
Original file line number Diff line number Diff line change
@@ -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
}

}
14 changes: 14 additions & 0 deletions infra/blockchain/vpc/outputs.tf
Original file line number Diff line number Diff line change
@@ -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."
}
13 changes: 13 additions & 0 deletions infra/blockchain/vpc/variables.tf
Original file line number Diff line number Diff line change
@@ -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
}
14 changes: 11 additions & 3 deletions infra/vpc/main.tf
Original file line number Diff line number Diff line change
@@ -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" {
Expand All @@ -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
}

}
33 changes: 6 additions & 27 deletions infra/vpc/variables.tf
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 9887cd4

Please sign in to comment.