-
Notifications
You must be signed in to change notification settings - Fork 1
/
vpc.tf
44 lines (40 loc) · 1.14 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
provider "aws" {
region = "ca-central-1"
}
resource "aws_vpc" "kubernetes" {
cidr_block = var.vpc_cidr
tags = {
Name = "kubernetes"
}
}
resource "aws_internet_gateway" "kubernetes_vpc_igw" {
vpc_id = aws_vpc.kubernetes.id
tags = {
Name = "kubernetes_vpc_igw"
}
}
resource "aws_subnet" "kubernetes_subnets" {
count = length(var.subnets_cidr)
vpc_id = aws_vpc.kubernetes.id
cidr_block = element(var.subnets_cidr, count.index)
availability_zone = element(var.availability_zones, count.index)
map_public_ip_on_launch = true
tags = {
Name = "kubernetes_subnets_${count.index + 1}"
}
}
resource "aws_route_table" "kubernetes_public_rt" {
vpc_id = aws_vpc.kubernetes.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.kubernetes_vpc_igw.id
}
tags = {
Name = "kubernetes_vpc_public_rt"
}
}
resource "aws_route_table_association" "rt_sub_association" {
count = length(var.subnets_cidr)
subnet_id = element(aws_subnet.kubernetes_subnets.*.id, count.index)
route_table_id = aws_route_table.kubernetes_public_rt.id
}