-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
64 lines (56 loc) · 1.74 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
provider "aws" {
region = "${var.region}"
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
}
# "web: ${aws_instance.prod-web.public_ip}",
# "db: ${aws_instance.prod-db.public_ip}",
#TODO: get this to work without having to specify the instances explicitly
output "public_ips" {
value = [
"staging: ${aws_instance.staging.public_ip}"
]
}
resource "aws_instance" "staging" {
ami = "ami-cd0f5cb6"
instance_type = "t2.small"
#TODO: this needs to be set as an environment variable
key_name = "${var.keypair}"
# add iam role from above
iam_instance_profile = "${aws_iam_instance_profile.staging-bchd-ec2-role.name}"
# Our Security group to allow HTTP access
vpc_security_group_ids = ["${aws_security_group.staging-vpc-sg.id}"]
subnet_id = "${aws_subnet.staging.id}"
user_data = "${file("./userdata_staging.sh")}"
}
# resource "aws_instance" "prod-web" {
# ami = "ami-cd0f5cb6"
# instance_type = "t2.micro"
#
# key_name = "${var.keypair}"
#
# # add iam role from above
# iam_instance_profile = "${aws_iam_instance_profile.prod-bchd-ec2-role.name}"
#
# # Our Security group to allow HTTP access
# vpc_security_group_ids = ["${aws_security_group.prod-vpc-sg.id}"]
#
# subnet_id = "${aws_subnet.prod.id}"
# user_data = "${file("./userdata_prod_web.sh")}"
# }
#
# resource "aws_instance" "prod-db" {
# ami = "ami-cd0f5cb6"
# instance_type = "t2.small"
#
# key_name = "${var.keypair}"
#
# # add iam role from above
# iam_instance_profile = "${aws_iam_instance_profile.prod-bchd-ec2-role.name}"
#
# # Our Security group to allow HTTP access
# vpc_security_group_ids = ["${aws_security_group.prod-vpc-sg.id}"]
#
# subnet_id = "${aws_subnet.prod.id}"
# user_data = "${file("./userdata_prod_db.sh")}"
# }