-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
71 lines (61 loc) · 1.36 KB
/
main.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
provider "aws" {
access_key = "${var.AWS_ACCESS_KEY}"
secret_key = "${var.AWS_SECRET_KEY}"
region = "${var.AWS_REGION}"
}
resource "aws_security_group" "allow_all" {
name = "allow_all"
description = "Allow all inbound traffic"
ingress {
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
Name = "allow_all"
}
}
resource "aws_instance" "api-0" {
ami = "${var.AWS_AMI}"
instance_type = "t2.micro"
key_name = "${var.AWS_INSTANCE_KEY_NAME}"
security_groups = [
"${aws_security_group.allow_all.name}"
]
tags {
Name = "API-0"
Owner = "dgomez"
}
}
resource "aws_instance" "api-1" {
ami = "${var.AWS_AMI}"
instance_type = "t2.micro"
key_name = "${var.AWS_INSTANCE_KEY_NAME}"
security_groups = [
"${aws_security_group.allow_all.name}"
]
tags {
Name = "API-1"
Owner = "dgomez"
}
}
resource "aws_instance" "load-balancer-0" {
ami = "${var.AWS_AMI}"
instance_type = "t2.micro"
key_name = "${var.AWS_INSTANCE_KEY_NAME}"
security_groups = [
"${aws_security_group.allow_all.name}"
]
user_data = "${file("balancer.sh")}"
tags {
Name = "LB-0"
Owner = "dgomez"
}
}