-
Notifications
You must be signed in to change notification settings - Fork 1
/
vpc.tf
39 lines (34 loc) · 1.24 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
# Resources Block
# Resource-1: Create VPC
resource "aws_vpc" "vpc-kubernetes" {
cidr_block = "10.0.0.0/16"
tags = {
"Name" = "vpc-kubernetes"
}
}
# Resource-2: Create Subnets
resource "aws_subnet" "vpc-kubernetes-public-subnet-1" {
vpc_id = aws_vpc.vpc-kubernetes.id
cidr_block = "10.0.1.0/24"
availability_zone = "eu-west-1a"
map_public_ip_on_launch = true
}
# Resource-3: Internet Gateway
resource "aws_internet_gateway" "vpc-kubernetes-igw" {
vpc_id = aws_vpc.vpc-kubernetes.id
}
# Resource-4: Create Route Table
resource "aws_route_table" "vpc-kubernetes-public-route-table" {
vpc_id = aws_vpc.vpc-kubernetes.id
}
# Resource-5: Create Route in Route Table for Internet Access
resource "aws_route" "vpc-kubernetes-public-route" {
route_table_id = aws_route_table.vpc-kubernetes-public-route-table.id
destination_cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.vpc-kubernetes-igw.id
}
# Resource-6: Associate the Route Table with the Subnet
resource "aws_route_table_association" "vpc-kubernetes-public-route-table-associate" {
route_table_id = aws_route_table.vpc-kubernetes-public-route-table.id
subnet_id = aws_subnet.vpc-kubernetes-public-subnet-1.id
}