-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc.tf
55 lines (47 loc) · 1.39 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
55
data "aws_region" "current" {}
locals {
public_subnet_ids = [
aws_subnet.public_subnet_1.id,
aws_subnet.public_subnet_2.id,
]
}
resource "aws_vpc" "main_vpc" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = "true"
}
resource "aws_subnet" "public_subnet_1" {
vpc_id = aws_vpc.main_vpc.id
cidr_block = "10.0.64.0/19"
availability_zone = "${data.aws_region.current.name}a"
map_public_ip_on_launch = true
tags = {
"kubernetes.io/role/elb" = "1"
}
}
resource "aws_subnet" "public_subnet_2" {
vpc_id = aws_vpc.main_vpc.id
cidr_block = "10.0.96.0/19"
availability_zone = "${data.aws_region.current.name}b"
map_public_ip_on_launch = true
tags = {
"kubernetes.io/role/elb" = "1"
}
}
resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.main_vpc.id
}
resource "aws_route_table" "public_route_table" {
vpc_id = aws_vpc.main_vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.igw.id
}
}
resource "aws_route_table_association" "public_route_table_association_1" {
route_table_id = aws_route_table.public_route_table.id
subnet_id = aws_subnet.public_subnet_1.id
}
resource "aws_route_table_association" "public_route_table_association_2" {
route_table_id = aws_route_table.public_route_table.id
subnet_id = aws_subnet.public_subnet_2.id
}