forked from ngerakines/terraform-docker-swarm-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.tf
149 lines (126 loc) · 2.91 KB
/
provider.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
provider "aws" {
region = "${var.aws_region}"
}
resource "aws_internet_gateway" "main" {
vpc_id = "${aws_vpc.vpc.id}"
tags {
Name = "${var.vpc_key}-ig"
VPC = "${var.vpc_key}"
Terraform = "Terraform"
}
}
resource "aws_network_acl" "network" {
vpc_id = "${aws_vpc.vpc.id}"
subnet_ids = [
"${aws_subnet.a.id}",
"${aws_subnet.b.id}",
"${aws_subnet.c.id}"
]
ingress {
from_port = 0
to_port = 0
rule_no = 100
action = "allow"
protocol = "-1"
cidr_block = "0.0.0.0/0"
}
egress {
from_port = 0
to_port = 0
rule_no = 100
action = "allow"
protocol = "-1"
cidr_block = "0.0.0.0/0"
}
tags {
Name = "${var.vpc_key}-network"
VPC = "${var.vpc_key}"
Terraform = "Terraform"
}
}
resource "aws_route_table" "main" {
vpc_id = "${aws_vpc.vpc.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.main.id}"
}
tags {
Name = "${var.vpc_key}-route"
VPC = "${var.vpc_key}"
Terraform = "Terraform"
}
}
resource "aws_route_table_association" "a" {
route_table_id = "${aws_route_table.main.id}"
subnet_id = "${aws_subnet.a.id}"
}
resource "aws_route_table_association" "b" {
route_table_id = "${aws_route_table.main.id}"
subnet_id = "${aws_subnet.b.id}"
}
resource "aws_route_table_association" "c" {
route_table_id = "${aws_route_table.main.id}"
subnet_id = "${aws_subnet.c.id}"
}
resource "aws_subnet" "a" {
vpc_id = "${aws_vpc.vpc.id}"
cidr_block = "${cidrsubnet(aws_vpc.vpc.cidr_block,8,1)}"
availability_zone = "${var.aws_region}a"
map_public_ip_on_launch = false
tags {
Name = "${var.vpc_key}-a"
VPC = "${var.vpc_key}"
Terraform = "Terraform"
}
}
resource "aws_subnet" "b" {
vpc_id = "${aws_vpc.vpc.id}"
cidr_block = "${cidrsubnet(aws_vpc.vpc.cidr_block,8,2)}"
availability_zone = "${var.aws_region}b"
map_public_ip_on_launch = false
tags {
Name = "${var.vpc_key}-b"
VPC = "${var.vpc_key}"
Terraform = "Terraform"
}
}
resource "aws_subnet" "c" {
vpc_id = "${aws_vpc.vpc.id}"
cidr_block = "${cidrsubnet(aws_vpc.vpc.cidr_block,8,3)}"
availability_zone = "${var.aws_region}c"
map_public_ip_on_launch = false
tags {
Name = "${var.vpc_key}-c"
VPC = "${var.vpc_key}"
Terraform = "Terraform"
}
}
resource "aws_vpc" "vpc" {
cidr_block = "10.25.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
instance_tenancy = "default"
tags {
VPC = "${var.vpc_key}"
Name = "${var.vpc_key}-vpc"
Terraform = "Terraform"
}
}
output "vpc_id" {
value = "${aws_vpc.vpc.id}"
}
output "vcp_cidr_1" {
value = "${cidrhost(aws_vpc.vpc.cidr_block,1)}"
}
output "vcp_cidr_sub_1" {
value = "${cidrsubnet(aws_vpc.vpc.cidr_block,8,1)}"
}
output "vpc_subnet_a" {
value = "${aws_subnet.a.id}"
}
output "vpc_subnet_b" {
value = "${aws_subnet.b.id}"
}
output "vpc_subnet_c" {
value = "${aws_subnet.c.id}"
}