-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathvpc.tf
55 lines (43 loc) · 1.15 KB
/
vpc.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#
# VPC Resources
# * VPC
# * Subnets
# * Internet Gateway
# * Route Table
#
resource "aws_vpc" "eks" {
cidr_block = "${var.vpc-network}.0.0/16"
tags = {
"Name" = "eks-${var.cluster-name}"
"kubernetes.io/cluster/${var.cluster-name}" = "shared"
}
}
resource "aws_subnet" "eks" {
count = var.vpc-subnets
availability_zone = data.aws_availability_zones.available.names[count.index]
cidr_block = "${var.vpc-network}.${count.index}.0/24"
vpc_id = aws_vpc.eks.id
map_public_ip_on_launch = true
tags = {
"Name" = "eks-${var.cluster-name}"
"kubernetes.io/cluster/${var.cluster-name}" = "shared"
}
}
resource "aws_internet_gateway" "eks" {
vpc_id = aws_vpc.eks.id
tags = {
Name = "eks-${var.cluster-name}"
}
}
resource "aws_route_table" "eks" {
vpc_id = aws_vpc.eks.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.eks.id
}
}
resource "aws_route_table_association" "eks" {
count = var.vpc-subnets
subnet_id = aws_subnet.eks[count.index].id
route_table_id = aws_route_table.eks.id
}