-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublic_subnet-gateway.tf
62 lines (53 loc) · 1.4 KB
/
public_subnet-gateway.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
56
57
58
59
60
61
# public_subnet 1 생성
resource "aws_subnet" "public_subnet_1a" {
vpc_id = aws_vpc.vpc.id
cidr_block = "10.10.1.0/28"
availability_zone = "ap-northeast-2c"
tags = {
Name = "public_subnet_1a"
}
}
# public_subnet 2 생성
resource "aws_subnet" "public_subnet_1b" {
vpc_id = aws_vpc.vpc.id
cidr_block = "10.10.2.0/28"
availability_zone = "ap-northeast-2b"
tags = {
Name = "public_subnet_1b"
}
}
# Internet Gateway 생성
resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.vpc.id
tags = {
Name = "Internet Gateway"
}
}
# Route Table 생성
resource "aws_route_table" "public_route_1" {
vpc_id = aws_vpc.vpc.id
tags = {
Name = "Public-Route-1"
}
}
resource "aws_route_table" "public_route_2" {
vpc_id = aws_vpc.vpc.id
tags = {
Name = "Public-Route-2"
}
}
// route internet 연결
resource "aws_route" "internet_access_1" {
route_table_id = aws_route_table.public_route_1.id
destination_cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.igw.id
}
# Subnet Route 연결
resource "aws_route_table_association" "public_subnet_1" {
subnet_id = aws_subnet.public_subnet_1a.id
route_table_id = aws_route_table.public_route_1.id
}
resource "aws_route_table_association" "public_subnet_2" {
subnet_id = aws_subnet.public_subnet_1b.id
route_table_id = aws_route_table.public_route_2.id
}