Giter VIP home page Giter VIP logo

tf-module-network's Introduction

alt text

tf-module-network

Supported Resources:

Terraform Version

terraform 0.12

Requirements

  • Terraform
  • AWS Account

Providers

Name Version
aws ~> 2.0
terraform ~> 0.12.0

Example of Use


VPC:

module "vpc" {
  source = "github.com/leandromoreirati/tf-module-network/modules/vpc?ref=v0"

  name                 = "{var.my_team}-{var.product}-{var.environment}"
  cidr_block           = var.cidr_block        
  instance_tenancy     = var.instance_tenancy
  enable_dns_support   = var.enable_dns_support
  enable_dns_hostnames = var.enable_dns_hostnames 
  
  tags = {
    environment = "${var.environment}"
    Name = "${var.my_team}-${var.product}-${var.environment}"
    terraform      = true
  }
}

Subnet:

module "private_subnet" {
  source = "github.com/leandromoreirati/tf-module-network/modules/subnet"

  name                     = "{var.my_team}-{var.product}-{var.environment}"

  vpc_id                   = module.vpc.vpc_id
  cidr_block               = module.vpc.vpc_cidr_block
  az_count                 = var.az_count
  map_public_ip_on_launch  = var.map_public_ip_on_launch

  tags = {
    environment = "${var.environment}"
    Name = "${var.my_team}-${var.product}-${var.environment}"
    terraform      = true
  }
}

Route Table:

module "route_table" {
  source = "github.com/leandromoreirati/tf-module-network/modules/route-table"
  
  az_count = var.az_count
  vpc_id   = module.vpc.vpc_id
  private_subnet_id = module.private_subnet.private_subnet_id

  route_rules =[
    {
      cidr_block = "0.0.0.0/0"
      gateway_id = module.internet_gateway.internet_gateway_id
      nat_gateway_id = ""
      transit_gateway_id = ""
      vpc_peering_connection_id = ""
    },
  ]

  tags = {
    environment = "${var.environment}"
    Name = "rt-private-subnet-${var.environment}"
    terraform     = true
  }

}

Elastic IP:

module "elastic_ip" {
  source = "github.com/leandromoreirati/tf-module-network/modules/elastic-ip

  tags = {
     Name            = "eip-${var.my_team}-${var.product}-${var.environment}"
     environment     = var.environment
     terraform       = true
  }
}

NAT Gateway:

module "nat_gateway" {
  source = "github.com/leandromoreirati/tf-module-network/modules/nat-gateway"

  subnet_count = length(data.aws_subnet_ids.private.ids)

  allocation_id     = module.elastic_ip.elastic_ip_id
  private_subnet_id = data.aws_subnet_ids.private.ids[*]

  tags = {
     Name            = "ng-${var.my_team}-${var.product}-${var.environment}"
     environment     = var.environment
     terraform       = true
  }
}

NAT Gateway:

module "nat_gateway" {
  source = "github.com/leandromoreirati/tf-module-network/modules/nat-gateway"

  subnet_count = length(data.aws_subnet_ids.private.ids)
  allocation_id = ["eipalloc-0f44c3d48e39f48ab",
                   "eipalloc-035995232234b185d",
                   "eipalloc-09f21475564212c3d"
                  ]
  private_subnet_id = ["subnet-0b13e74cbc4a854a4",
                       "subnet-0338537d482a6fd45",
                       "subnet-08ada95ce3df91472"
                      ] 

  tags = {
     Name            = "ng-${var.my_team}-${var.product}-${var.environment}"
     environment     = var.environment
     terraform       = true
  }
}

Internet Gateway:

module "internet_gateway" {
  source = "github.com/leandromoreirati/tf-module-network/modules/internet-gateway"

  vpc_id = module.vpc.vpc_id

  tags = {
    environment = "${var.environment}"
    Name = "${var.my_team}-${var.product}-${var.environment}"
    terraform      = true
  }
}

Security Group:

module "security_group" {
  source = "github.com/leandromoreirati/tf-module-network/modules/security-group"

  name = "${var.my_team}-${var.product}-${var.environment}"

  description   = var.description
  vpc_id        = var.vpc_id

  ingress_rules = [
    {
      from_port  = 22
      to_port    = 22
      protocol   = "tcp"
      cidr_blocks = ["172.20.21.0/24"]
      security_groups = ["sg-04f207a5915da6e23"]
    },
    {
      from_port  = 80
      to_port    = 80
      protocol   = "udp"
      cidr_blocks = ["0.0.0.0/0"]
    },
    {
      from_port  = 443
      to_port    = 443
      protocol   = "tcp"
      cidr_blocks = ["0.0.0.0/0"]
    },
  ]

  egress_rules = [
    {
      from_port  = 0
      to_port    = 0
      protocol   = "-1"
      cidr_blocks = ["0.0.0.0/0"]
    },
  ]

  tags = {
     Name"           = "${var.my_team}-${var.product}-${var.environment}"
     environment     = var.environment
     Terraform         = true 
  }
} 

External Documentation

Features


  • VPC
  • Subnet
  • Route Table
  • Elastic IP
  • NAT Gateway
  • Internet Gateway
  • Security Group

tf-module-network's People

Watchers

Leandro Moreira avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.