-
Notifications
You must be signed in to change notification settings - Fork 1
/
aws_instances.tf
79 lines (79 loc) · 2.39 KB
/
aws_instances.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
resource "aws_instance" "redis" {
ami = "ami-cfca25a0"
instance_type = "t2.micro"
security_groups = ["${aws_security_group.ssh.name}", "${aws_security_group.outgoing.name}", "${aws_security_group.redis.name}"]
key_name = "${aws_key_pair.deployer.key_name}"
connection {
user = "core"
}
provisioner "remote-exec" {
inline = [
"docker run -dp 6379:6379 redis",
]
}
}
resource "aws_instance" "db" {
ami = "ami-cfca25a0"
instance_type = "t2.micro"
security_groups = ["${aws_security_group.ssh.name}", "${aws_security_group.postgres.name}", "${aws_security_group.outgoing.name}"]
key_name = "${aws_key_pair.deployer.key_name}"
connection {
user = "core"
}
provisioner "remote-exec" {
inline = [
"docker run -dp 5432:5432 postgres",
]
}
}
resource "aws_instance" "voting" {
ami = "ami-cfca25a0"
instance_type = "t2.micro"
security_groups = ["${aws_security_group.ssh.name}", "${aws_security_group.http.name}", "${aws_security_group.outgoing.name}"]
key_name = "${aws_key_pair.deployer.key_name}"
connection {
user = "core"
}
provisioner "remote-exec" {
inline = [
"docker run -dp 80:80 -e REDIS_HOST=${aws_instance.redis.private_ip} ditmc/voting",
]
}
}
resource "aws_instance" "worker" {
ami = "ami-cfca25a0"
instance_type = "t2.micro"
security_groups = ["${aws_security_group.ssh.name}", "${aws_security_group.outgoing.name}"]
key_name = "${aws_key_pair.deployer.key_name}"
connection {
user = "core"
}
provisioner "remote-exec" {
inline = [
"docker run -d -e REDIS_HOST=${aws_instance.redis.private_ip} -e DB_HOST=${aws_instance.db.private_ip} ditmc/worker"
]
}
}
resource "aws_instance" "result" {
ami = "ami-cfca25a0"
instance_type = "t2.micro"
security_groups = ["${aws_security_group.ssh.name}", "${aws_security_group.http.name}", "${aws_security_group.outgoing.name}"]
key_name = "${aws_key_pair.deployer.key_name}"
connection {
user = "core"
}
provisioner "remote-exec" {
inline = [
"docker run -dp 80:80 -e DB_HOST=${aws_instance.db.private_ip} ditmc/result"
]
}
}
resource "aws_eip" "voting_ip" {
instance = "${aws_instance.voting.id}"
}
resource "aws_eip" "db_ip" {
instance = "${aws_instance.db.id}"
}
resource "aws_eip" "result_ip" {
instance = "${aws_instance.result.id}"
}