-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubnet.tf
49 lines (39 loc) · 1.12 KB
/
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
data "aws_availability_zones" "available" {}
resource "aws_subnet" "subnet-1" {
vpc_id = "${aws_vpc.main.id}"
cidr_block = "10.0.1.0/24"
availability_zone = "${data.aws_availability_zones.available.names[0]}"
tags = {
Name = "Subnet-1"
}
}
resource "aws_subnet" "subnet-2" {
vpc_id = "${aws_vpc.main.id}"
cidr_block = "10.0.2.0/24"
availability_zone = "${data.aws_availability_zones.available.names[1]}"
tags = {
Name = "Subnet-2"
}
}
resource "aws_subnet" "subnet-3" {
vpc_id = "${aws_vpc.main.id}"
cidr_block = "10.0.3.0/24"
availability_zone = "${data.aws_availability_zones.available.names[2]}"
tags = {
Name = "Subnet-3"
}
}
resource "aws_route_table" "route-table-main-vpc" {
vpc_id = "${aws_vpc.main.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.main-vpc-igw.id}"
}
tags {
Name = "route-table-main-vpc"
}
}
resource "aws_route_table_association" "subnet-association" {
subnet_id = "${aws_subnet.subnet-1.id}"
route_table_id = "${aws_route_table.route-table-main-vpc.id}"
}