-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaws_infrastructure.tf
72 lines (58 loc) · 1.6 KB
/
aws_infrastructure.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
# Specifies the details for the base infrastructure such as VPC and subnets
# https://www.terraform.io/docs/providers/aws/
resource "aws_vpc" "waf_vpc" {
cidr_block = "${var.vpc_cidr}"
tags {
Name = "${var.id}_vpc"
Owner = "${var.owner}"
}
}
resource "aws_subnet" "pubnet" {
vpc_id = "${aws_vpc.waf_vpc.id}"
cidr_block = "${cidrsubnet(var.vpc_cidr, 8, 0)}"
availability_zone = "${lookup(var.aws_az, var.aws_region)}"
tags {
Name = "${var.id}_VIP_network"
Owner = "${var.owner}"
}
}
resource "aws_subnet" "privnet" {
vpc_id = "${aws_vpc.waf_vpc.id}"
cidr_block = "${cidrsubnet(var.vpc_cidr, 8, 1)}"
availability_zone = "${lookup(var.aws_az, var.aws_region)}"
tags {
Name = "${var.id}_server_network"
Owner = "${var.owner}"
}
}
resource "aws_subnet" "mgmtnet" {
vpc_id = "${aws_vpc.waf_vpc.id}"
cidr_block = "${cidrsubnet(var.vpc_cidr, 8, 2)}"
availability_zone = "${lookup(var.aws_az, var.aws_region)}"
tags {
Name = "${var.id}_management_network"
Owner = "${var.owner}"
}
}
resource "aws_internet_gateway" "igw" {
vpc_id = "${aws_vpc.waf_vpc.id}"
tags {
Name = "${var.id}_igw"
Owner = "${var.owner}"
}
}
resource "aws_route_table" "pubrt" {
vpc_id = "${aws_vpc.waf_vpc.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.igw.id}"
}
tags {
Name = "${var.id}_pubrt"
Owner = "${var.owner}"
}
}
resource "aws_route_table_association" "pubrta" {
subnet_id = "${aws_subnet.pubnet.id}"
route_table_id = "${aws_route_table.pubrt.id}"
}