Created
June 10, 2020 02:09
-
-
Save khalidx/2665df5a6d47c355c1a5cc8ebc1a5723 to your computer and use it in GitHub Desktop.
Simple, quick, and complete VPC setup for AWS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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