-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc.tf
51 lines (42 loc) · 1.22 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
resource "aws_vpc" "default" {
cidr_block = "${var.vpc_cidr}"
enable_dns_hostnames = true
tags {
Name = "${var.project_name}-vpc"
}
}
resource "aws_internet_gateway" "default" {
vpc_id = "${aws_vpc.default.id}"
}
resource "aws_subnet" "us-west-2-ec2" {
vpc_id = "${aws_vpc.default.id}"
count = 3
cidr_block = "${element(var.ec2_subnet_cidr, count.index)}"
availability_zone = "${element(var.ec2_az, count.index)}"
map_public_ip_on_launch = true
tags {
Name = "${var.project_name} web subnet"
}
}
resource "aws_route_table" "us-west-2-ec2" {
vpc_id = "${aws_vpc.default.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.default.id}"
}
tags {
Name = "Web routes"
}
}
resource "aws_route_table_association" "us-west-2-ec2" {
count = 3
subnet_id = "${element("${aws_subnet.us-west-2-ec2.*.id}", count.index)}"
route_table_id = "${element("${aws_route_table.us-west-2-ec2.*.id}", count.index)}"
}
resource "aws_db_subnet_group" "default" {
name = "${var.project_name}-rds-vps"
subnet_ids = ["${aws_subnet.us-west-2-ec2.*.id}"]
tags {
Name = "${var.project_name} RDS subnet"
}
}