Giter Club home page Giter Club logo

terraform-aws-vpc-1's Introduction

terraform-aws-vpc

CircleCI

A Terraform module to create an Amazon Web Services (AWS) Virtual Private Cloud (VPC).

Usage

This module creates a VPC alongside a variety of related resources, including:

  • Public and private subnets
  • Public and private route tables
  • Elastic IPs
  • Network Interfaces
  • NAT Gateways
  • An Internet Gateway
  • A VPC Endpoint
  • A bastion EC2 instance

Example usage:

module "vpc" {
  source = "github.com/azavea/terraform-aws-vpc"

  name = "Default"
  region = "us-east-1"
  key_name = "hector"
  cidr_block = "10.0.0.0/16"
  private_subnet_cidr_blocks = ["10.0.1.0/24", "10.0.3.0/24"]
  public_subnet_cidr_blocks = ["10.0.0.0/24", "10.0.2.0/24"]
  availability_zones = ["us-east-1a", "us-east-1b"]
  bastion_ami = "ami-6869aa05"
  bastion_ebs_optimized = true
  bastion_instance_type = "t3.micro"

  project = "Something"
  environment = "Staging"
}

Configuring security rules

By default, this module adds no security rules to the bastion instance, meaning that all traffic will be blocked.

In order to configure security rules for the bastion, use the bastion_security_group_id output. For example:

resource "aws_security_group_rule" "ssh_ingress" {
  security_group_id = module.vpc.bastion_security_group_id
  type              = "ingress"
  from_port         = 22
  to_port           = 22
  protocol          = "tcp"
  cidr_blocks       = [var.bastion_inbound_cidr_block]
}

There is a limit to the number of rules you can add to a security group. If you have exceeded this limit, you can add additional security groups to the bastion using the bastion_network_interface_id output and an aws_network_interface_sg_attachment resource. For example:

resource "aws_security_group" "ssh_ingress" {
  vpc_id = module.vpc.id

  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = [var.bastion_inbound_cidr_block]
  }
}

resource "aws_network_interface_sg_attachment" "sg_attachment" {
  security_group_id    = aws_security_group.ssh_ingress.id
  network_interface_id = module.vpc.bastion_network_interface_id
}

Variables

  • name - Name of the VPC (default: Default)
  • project - Name of project this VPC is meant to house (default: Unknown)
  • environment - Name of environment this VPC is targeting (default: Unknown)
  • region - Region of the VPC (default: us-east-1)
  • key_name - EC2 Key pair name for the bastion
  • cidr_block - CIDR block for the VPC (default: 10.0.0.0/16)
  • public_subnet_cidr_blocks - List of public subnet CIDR blocks (default: ["10.0.0.0/24","10.0.2.0/24"])
  • private_subnet_cidr_blocks - List of private subnet CIDR blocks (default: ["10.0.1.0/24", "10.0.3.0/24"])
  • availability_zones - List of availability zones (default: ["us-east-1a", "us-east-1b"])
  • bastion_ami - Bastion Amazon Machine Image (AMI) ID
  • bastion_ebs_optimized - If true, the bastion instance will be EBS-optimized (default: false)
  • bastion_instance_type - Instance type for bastion instance (default: t3.nano)
  • tags - Extra tags to attach to the VPC resources (default: {})

Outputs

  • id - VPC ID
  • public_subnet_ids - List of public subnet IDs
  • private_subnets_ids - List of private subnet IDs
  • bastion_hostname - Public DNS name for bastion instance
  • bastion_security_group_id - Security group ID tied to bastion instance
  • bastion_network_interface_id - Elastic Network Interface (ENI) ID of the Bastion instance's primary network interface
  • cidr_block - The CIDR block associated with the VPC
  • nat_gateway_ips - List of Elastic IPs associated with NAT gateways

terraform-aws-vpc-1's People

Contributors

hectcastro avatar rbreslow avatar tnation14 avatar jeancochrane avatar sharph avatar

Watchers

James Cloos 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.