-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpc.tf
93 lines (77 loc) · 2.04 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
resource "aws_vpc" "schiele" {
cidr_block = "10.0.0.0/16"
instance_tenancy = "default"
tags = {
Name = "Schiele VPC"
}
}
resource "aws_subnet" "sch-public1" {
vpc_id = aws_vpc.schiele.id
cidr_block = "10.0.1.0/24"
availability_zone = "eu-central-1a"
tags = {
Name = "Schiele public subnet 1"
}
}
resource "aws_subnet" "sch-public2" {
vpc_id = aws_vpc.schiele.id
cidr_block = "10.0.2.0/24"
availability_zone = "eu-central-1b"
tags = {
Name = "Schiele public subnet 2"
}
}
resource "aws_subnet" "sch-private1" {
vpc_id = aws_vpc.schiele.id
cidr_block = "10.0.8.0/24"
availability_zone = "eu-central-1b"
tags = {
Name = "Schiele private subnet 1"
}
}
resource "aws_subnet" "sch-private2" {
vpc_id = aws_vpc.schiele.id
cidr_block = "10.0.9.0/24"
availability_zone = "eu-central-1c"
tags = {
Name = "Schiele private subnet 2"
}
}
resource "aws_db_subnet_group" "subnet_group" {
name = "subnet_group"
subnet_ids = [aws_subnet.sch-private1.id, aws_subnet.sch-private2.id]
tags = {
Name = "My DB subnet group"
}
}
resource "aws_internet_gateway" "gw" {
vpc_id = aws_vpc.schiele.id
tags = {
Name = "Schiele internet gateway"
}
}
# resource "aws_nat_gateway" "sch_nat" {
# allocation_id = aws_eip.sch_nat.id
# subnet_id = aws_subnet.sch-public1.id
# tags = {
# Name = "NAT Gateway"
# }
# # To ensure proper ordering, it is recommended to add an explicit dependency
# # on the Internet Gateway for the VPC.
# depends_on = [aws_internet_gateway.gw]
# }
resource "aws_route_table" "sch_route_table" {
vpc_id = aws_vpc.schiele.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.gw.id
}
}
resource "aws_route_table_association" "rta_subnet_public1" {
subnet_id = aws_subnet.sch-public1.id
route_table_id = aws_route_table.sch_route_table.id
}
resource "aws_route_table_association" "rta_subnet_public2" {
subnet_id = aws_subnet.sch-public2.id
route_table_id = aws_route_table.sch_route_table.id
}