Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate*

# plan files
*.tfplan
25 changes: 25 additions & 0 deletions terraform/dev/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions terraform/dev/igw.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.main.id

tags = {
Name = "${local.environment}-igw"
environment = "${local.environment}"
}
}

resource "aws_nat_gateway" "aws_nat_gateway" {
allocation_id = aws_eip.nat.id
subnet_id = aws_subnet.public_zone1.id

tags = {
"Name" = "${local.environment}-nat"
}

depends_on = [aws_internet_gateway.igw]
}
8 changes: 8 additions & 0 deletions terraform/dev/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
locals {
environment = "dev"
region = "us-east-1"
zone1 = "us-east-1a"
zone2 = "us-east-1b"
eks_name = "dieubernetes"
eks_version = "1.30"
}
8 changes: 8 additions & 0 deletions terraform/dev/nat.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# translates private machine IP addresses into public ones
resource "aws_eip" "nat" {
domain = "vpc"

tags = {
"Name" = "${local.environment}-nat"
}
}
14 changes: 14 additions & 0 deletions terraform/dev/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
provider "aws" {
region = local.region
}

terraform {
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.64"
}
}
}
45 changes: 45 additions & 0 deletions terraform/dev/routes.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
resource "aws_route_table" "private" {
vpc_id = aws_vpc.main.id

route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.aws_nat_gateway.id
}

tags = {
"Name" = "${local.environment}-private"
}
}

resource "aws_route_table" "public" {
vpc_id = aws_vpc.main.id

route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.igw.id
}

tags = {
"Name" = "${local.environment}-public"
}
}

resource "aws_route_table_association" "private_zone1" {
route_table_id = aws_route_table.private.id
subnet_id = aws_subnet.private_zone1.id
}

resource "aws_route_table_association" "private_zone2" {
route_table_id = aws_route_table.private.id
subnet_id = aws_subnet.private_zone2.id
}

resource "aws_route_table_association" "public_zone1" {
route_table_id = aws_route_table.public.id
subnet_id = aws_subnet.public_zone1.id
}

resource "aws_route_table_association" "public_zone2" {
route_table_id = aws_route_table.public.id
subnet_id = aws_subnet.public_zone2.id
}
48 changes: 48 additions & 0 deletions terraform/dev/subnets.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
resource "aws_subnet" "private_zone1" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.0.0/19"
availability_zone = local.zone1

tags = {
Name = "${local.environment}-private-${local.zone1}"
"kubernetes.io/role/internal-elb" = "1" # allows us to expose services internally within the vpc
"kubernetes.io/cluster/${local.environment}-${local.eks_name}" = "owned"
}
}

resource "aws_subnet" "private_zone2" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.32.0/19"
availability_zone = local.zone2
tags = {
Name = "${local.environment}-private-${local.zone1}"
"kubernetes.io/role/internal-elb" = "1" # allows us to expose services internally within the vpc
"kubernetes.io/cluster/${local.environment}-${local.eks_name}" = "owned"
}
}

resource "aws_subnet" "public_zone1" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.64.0/19"
availability_zone = local.zone1
map_public_ip_on_launch = true

tags = {
"Name" = "${local.environment}-public-${local.zone1}"
"kubernetes.io/role/elb" = "1"
"kubernetes.io/cluster/${local.environment}-${local.eks_name}" = "owned"
}
}

resource "aws_subnet" "public_zone2" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.96.0/19"
availability_zone = local.zone2
map_public_ip_on_launch = true

tags = {
"Name" = "${local.environment}-public-${local.zone2}"
"kubernetes.io/role/elb" = "1"
"kubernetes.io/cluster/${local.environment}-${local.eks_name}" = "owned"
}
}
15 changes: 15 additions & 0 deletions terraform/dev/vpc.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"

# requirement for EFS, CSI driver, client VPNs
enable_dns_support = true
enable_dns_hostnames = true

tags = {
Name = "${local.environment}-main"
environment = "${local.environment}"
}
}

data "aws_availability_zones" "available" {}