Skip to content

Instantly share code, notes, and snippets.

@khalidx
Created June 10, 2020 02:09
Show Gist options
  • Save khalidx/2665df5a6d47c355c1a5cc8ebc1a5723 to your computer and use it in GitHub Desktop.
Save khalidx/2665df5a6d47c355c1a5cc8ebc1a5723 to your computer and use it in GitHub Desktop.
Simple, quick, and complete VPC setup for AWS
locals {
region = "us-east-1"
namespace = "infrastructure"
}
provider "aws" {
region = local.region
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "2.39.0"
name = "${local.namespace}-vpc"
cidr = "10.11.0.0/16"
azs = ["us-east-1a", "us-east-1b", "us-east-1c"]
private_subnets = ["10.11.0.0/20", "10.11.16.0/20", "10.11.32.0/20"]
public_subnets = ["10.11.48.0/20", "10.11.64.0/20", "10.11.80.0/20"]
enable_nat_gateway = true
enable_vpn_gateway = true
tags = {
Terraform = "true"
Environment = "dev"
}
}
output "console-urls" {
value = {
vpc = "https://console.aws.amazon.com/vpc/home?region=${local.region}#vpcs:VpcId=${module.vpc.vpc_id}"
subnets = "https://console.aws.amazon.com/vpc/home?region=${local.region}#subnets:VpcId=${module.vpc.vpc_id};sort=CidrBlock"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment