forked from Akiranred/tf-class-files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
84 lines (68 loc) · 1.63 KB
/
main.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
80
81
82
83
84
# VPC
resource "aws_vpc" "ibm" {
cidr_block = "10.0.0.0/16"
instance_tenancy = "default"
tags = {
Name = "IBM"
}
}
# Public Subnet
resource "aws_subnet" "ibm_pub_sb" {
vpc_id = aws_vpc.ibm.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-1b"
map_public_ip_on_launch = "true"
tags = {
Name = "IBM-PUB-SB"
}
}
# Private Subnet
resource "aws_subnet" "ibm_pvt_sb" {
vpc_id = aws_vpc.ibm.id
cidr_block = "10.0.2.0/24"
availability_zone = "us-west-1a"
map_public_ip_on_launch = "false"
tags = {
Name = "IBM-PVT-SB"
}
}
# Internet Gateway
resource "aws_internet_gateway" "ibm_igw" {
vpc_id = aws_vpc.ibm.id
tags = {
Name = "IBM-IGW"
}
}
# Public Route Table
resource "aws_route_table" "ibm_pub_rt" {
vpc_id = aws_vpc.ibm.id
tags = {
Name = "IBM-PUB-RT"
}
}
output "aws_route_table_public_ids" {
value = aws_route_table.ibm_pub_rt.id
}
resource "aws_route" "public_internet_gateway" {
route_table_id = aws_route_table.ibm_pub_rt.id
destination_cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.ibm_igw.id
}
# Private Route Table
# Default is private
resource "aws_route_table" "ibm_pvt_rt" {
vpc_id = aws_vpc.ibm.id
tags = {
Name = "IBM-PVT-RT"
}
}
# Public Route Table Association
resource "aws_route_table_association" "ibm_pub_assoc" {
subnet_id = aws_subnet.ibm_pub_sb.id
route_table_id = aws_route_table.ibm_pub_rt.id
}
# Private Route Table Association
resource "aws_route_table_association" "ibm_pvt_assoc" {
subnet_id = aws_subnet.ibm_pvt_sb.id
route_table_id = aws_route_table.ibm_pvt_rt.id
}