-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc.tf
80 lines (62 loc) · 1.61 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
resource "aws_vpc" "main_vpc" {
cidr_block = var.vpc_cidr
enable_dns_hostnames = true
tags = {
Name = "terraform-aws-vpc-rcm"
}
}
resource "aws_eip" "nat" {
instance = aws_instance.nat.id
vpc = true
}
resource "aws_eip" "web-1" {
instance = aws_instance.web-1.id
vpc = true
}
resource "aws_route_table" "ap-northeast-2a-public" {
vpc_id = aws_vpc.main_vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.ig-main.id
}
tags = {
Name = "Public Subnet"
}
}
resource "aws_route_table_association" "ap-northeast-2a-public" {
subnet_id = aws_subnet.ap-northeast-2a-public.id
route_table_id = aws_route_table.ap-northeast-2a-public.id
}
resource "aws_route_table" "ap-northeast-2b-private" {
vpc_id = aws_vpc.main_vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.ig-main.id
}
tags = {
Name = "Private Subnet"
}
}
resource "aws_route_table_association" "ap-northeast-2b-private" {
subnet_id = aws_subnet.ap-northeast-2b-private.id
route_table_id = aws_route_table.ap-northeast-2b-private.id
}
resource "aws_subnet" "ap-northeast-2a-public" {
vpc_id = aws_vpc.main_vpc.id
cidr_block = var.public_subnet_cidr
availability_zone = "ap-northeast-2a"
tags = {
Name = "Public Subnet"
}
}
resource "aws_subnet" "ap-northeast-2b-private" {
vpc_id = aws_vpc.main_vpc.id
cidr_block = var.private_subnet_cidr
availability_zone = "ap-northeast-2b"
tags = {
Name = "Private Subnet"
}
}
resource "aws_internet_gateway" "ig-main" {
vpc_id = aws_vpc.main_vpc.id
}