-
Notifications
You must be signed in to change notification settings - Fork 43
/
private-subnet.tf
62 lines (52 loc) · 1.66 KB
/
private-subnet.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
/* Private subnet */
resource "aws_subnet" "private_az1" {
vpc_id = "${aws_vpc.default.id}"
cidr_block = "${var.private_subnet_az1_cidr}"
availability_zone = "eu-west-1a"
map_public_ip_on_launch = false
depends_on = ["aws_instance.nat"]
tags {
Name = "private az1"
}
}
resource "aws_subnet" "private_az2" {
vpc_id = "${aws_vpc.default.id}"
cidr_block = "${var.private_subnet_az2_cidr}"
availability_zone = "eu-west-1b"
map_public_ip_on_launch = false
depends_on = ["aws_instance.nat"]
tags {
Name = "private az2"
}
}
resource "aws_subnet" "private_az3" {
vpc_id = "${aws_vpc.default.id}"
cidr_block = "${var.private_subnet_az3_cidr}"
availability_zone = "eu-west-1c"
map_public_ip_on_launch = false
depends_on = ["aws_instance.nat"]
tags {
Name = "private az3"
}
}
/* Routing table for private subnet */
resource "aws_route_table" "private" {
vpc_id = "${aws_vpc.default.id}"
route {
cidr_block = "0.0.0.0/0"
instance_id = "${aws_instance.nat.id}"
}
}
/* Associate the routing table to public subnets */
resource "aws_route_table_association" "private_az1" {
subnet_id = "${aws_subnet.private_az1.id}"
route_table_id = "${aws_route_table.private.id}"
}
resource "aws_route_table_association" "private_az2" {
subnet_id = "${aws_subnet.private_az2.id}"
route_table_id = "${aws_route_table.private.id}"
}
resource "aws_route_table_association" "private_az3" {
subnet_id = "${aws_subnet.private_az3.id}"
route_table_id = "${aws_route_table.private.id}"
}