Skip to content
Draft
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
34 changes: 32 additions & 2 deletions examples/existing-resources/vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true

tags = {
Name = var.project_name
}
}

resource "aws_internet_gateway" "main" {
vpc_id = aws_vpc.main.id

tags = {
Name = var.project_name
}
}

# Create three (one per AZ) public subnets (for NAT Gateways)
Expand All @@ -21,7 +29,10 @@ resource "aws_subnet" "public" {
availability_zone = data.aws_availability_zones.available.names[count.index]
map_public_ip_on_launch = true

tags = { "kubernetes.io/role/elb" = "1" }
tags = {
Name = "${var.project_name}-public-${data.aws_availability_zones.available.names[count.index]}"
"kubernetes.io/role/elb" = "1"
}
}

# Create three private subnets (for EKS nodes)
Expand All @@ -31,13 +42,20 @@ resource "aws_subnet" "private" {
cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index + 10)
availability_zone = data.aws_availability_zones.available.names[count.index]

tags = { "kubernetes.io/role/internal-elb" = "1" }
tags = {
Name = "${var.project_name}-private-${data.aws_availability_zones.available.names[count.index]}"
"kubernetes.io/role/internal-elb" = "1"
}
}

# Create Elastic IP for NAT Gateway
resource "aws_eip" "nat" {
domain = "vpc"

tags = {
Name = "${var.project_name}-${data.aws_availability_zones.available.names[0]}"
}

depends_on = [aws_internet_gateway.main]
}

Expand All @@ -46,6 +64,10 @@ resource "aws_nat_gateway" "main" {
allocation_id = aws_eip.nat.id
subnet_id = aws_subnet.public[0].id

tags = {
Name = "${var.project_name}-${data.aws_availability_zones.available.names[0]}"
}

depends_on = [aws_internet_gateway.main]
}

Expand All @@ -57,6 +79,10 @@ resource "aws_route_table" "public" {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.main.id
}

tags = {
Name = "${var.project_name}-public"
}
}

# Associate public subnets with public route table
Expand All @@ -74,6 +100,10 @@ resource "aws_route_table" "private" {
cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.main.id
}

tags = {
Name = "${var.project_name}-private"
}
}

# Associate private subnets with the route table
Expand Down
Loading