diff --git a/src/aws/elastic_ip.tf b/src/aws/elastic_ip.tf new file mode 100644 index 0000000..0361061 --- /dev/null +++ b/src/aws/elastic_ip.tf @@ -0,0 +1 @@ +resource "aws_eip" "gambley_nat_eip" {} diff --git a/src/aws/gateways.tf b/src/aws/gateways.tf new file mode 100644 index 0000000..ac6d7ac --- /dev/null +++ b/src/aws/gateways.tf @@ -0,0 +1,8 @@ +resource "aws_internet_gateway" "gambley_internet_gateway" { + vpc_id = aws_vpc.gambley_vpc.id +} + +resource "aws_nat_gateway" "gambley_nat_gateway" { + allocation_id = aws_eip.gambley_nat_eip.id + subnet_id = aws_subnet.gambley_subnet_public.id +} diff --git a/src/aws/route_tables.tf b/src/aws/route_tables.tf new file mode 100644 index 0000000..8a2b73f --- /dev/null +++ b/src/aws/route_tables.tf @@ -0,0 +1,25 @@ +resource "aws_route_table" "gambley_private_route_table" { + vpc_id = aws_vpc.gambley_vpc.id + route { + cidr_block = "0.0.0.0/0" + gateway_id = aws_nat_gateway.gambley_nat_gateway.id + } +} + +resource "aws_route_table" "gambley_public_route_table" { + vpc_id = aws_vpc.gambley_vpc.id + route { + cidr_block = "0.0.0.0/0" + gateway_id = aws_internet_gateway.gambley_internet_gateway.id + } +} + +resource "aws_route_table_association" "gambley_private_route_table_association" { + subnet_id = aws_subnet.gambley_subnet_private.id + route_table_id = aws_route_table.gambley_private_route_table.id +} + +resource "aws_route_table_association" "gambley_public_route_table_association" { + subnet_id = aws_subnet.gambley_subnet_public.id + route_table_id = aws_route_table.gambley_public_route_table.id +} diff --git a/src/aws/subnet.tf b/src/aws/subnet.tf new file mode 100644 index 0000000..e9e597e --- /dev/null +++ b/src/aws/subnet.tf @@ -0,0 +1,13 @@ +resource "aws_subnet" "gambley_subnet_private" { + vpc_id = aws_vpc.gambley_vpc.id + cidr_block = "10.0.1.0/24" + availability_zone = "ap-south-1a" + map_public_ip_on_launch = "false" +} + +resource "aws_subnet" "gambley_subnet_public" { + vpc_id = aws_vpc.gambley_vpc.id + cidr_block = "10.0.2.0/24" + availability_zone = "ap-south-1a" + map_public_ip_on_launch = "true" +} diff --git a/src/aws/vpc.tf b/src/aws/vpc.tf new file mode 100644 index 0000000..42815b3 --- /dev/null +++ b/src/aws/vpc.tf @@ -0,0 +1,3 @@ +resource "aws_vpc" "gambley_vpc" { + cidr_block = "10.0.0.0/16" +}