Created
May 13, 2019 02:26
-
-
Save mschirbel/6e5d6f4da3ad1c07462415934d884c1e to your computer and use it in GitHub Desktop.
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
resource "aws_vpc" "main_vpc" { | |
cidr_block = "${var.vpc_cidr}" | |
enable_dns_hostnames = true | |
tags { | |
Name = "terraform-aws-vpc" | |
} | |
} | |
resource "aws_eip" "nat" { | |
instance = "${aws_instance.nat.id}" | |
vpc = true | |
} | |
resource "aws_eip" "web-1" { | |
instance = "${aws_instance.web-1.id}" | |
vpc = true | |
} | |
resource "aws_route_table" "sa-east-1a-public" { | |
vpc_id = "${aws_vpc.main_vpc.id}" | |
route { | |
cidr_block = "0.0.0.0/0" | |
gateway_id = "${aws_internet_gateway.ig-main.id}" | |
} | |
tags { | |
Name = "Public Subnet" | |
} | |
} | |
resource "aws_route_table" "sa-east-1a-public" { | |
vpc_id = "${aws_vpc.main_vpc.id}" | |
route { | |
cidr_block = "0.0.0.0/0" | |
gateway_id = "${aws_internet_gateway.ig-main.id}" | |
} | |
tags { | |
Name = "Public Subnet" | |
} | |
} | |
resource "aws_route_table_association" "sa-east-1a-public" { | |
subnet_id = "${aws_subnet.sa-east-1a-public.id}" | |
route_table_id = "${aws_route_table.sa-east-1a-public.id}" | |
} | |
resource "aws_route_table" "sa-east-1a-private" { | |
vpc_id = "${aws_vpc.main_vpc.id}" | |
route { | |
cidr_block = "0.0.0.0/0" | |
instance_id = "${aws_instance.nat.id}" | |
} | |
tags { | |
Name = "Private Subnet" | |
} | |
} | |
resource "aws_route_table_association" "sa-east-1a-private" { | |
subnet_id = "${aws_subnet.sa-east-1a-private.id}" | |
route_table_id = "${aws_route_table.sa-east-1a-private.id}" | |
} | |
resource "aws_subnet" "sa-east-1a-public" { | |
vpc_id = "${aws_vpc.main_vpc.id}" | |
cidr_block = "${var.public_subnet_cidr}" | |
availability_zone = "sa-east-1a" | |
tags { | |
Name = "Public Subnet" | |
} | |
} | |
resource "aws_subnet" "sa-east-1a-private" { | |
vpc_id = "${aws_vpc.main_vpc.id}" | |
cidr_block = "${var.private_subnet_cidr}" | |
availability_zone = "sa-east-1a" | |
tags { | |
Name = "Private Subnet" | |
} | |
} | |
resource "aws_internet_gateway" "ig-main" { | |
vpc_id = "${aws_vpc.main_vpc.id}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment