-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathec2.tf
More file actions
50 lines (45 loc) · 1.82 KB
/
ec2.tf
File metadata and controls
50 lines (45 loc) · 1.82 KB
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
data "template_file" "script_file" {
template = "${file("${var.script_file}")}"
}
resource "aws_eip" "eip" {
count = "${var.eip_count}"
}
resource "aws_nat_gateway" "gw" {
count = "${var.eip_count}"
allocation_id = "${element(aws_eip.eip.*.id, count.index)}"
subnet_id = "${aws_subnet.public_subnet.*.id[count.index]}"
depends_on = ["aws_internet_gateway.my_igw"]
}
module "iam" {
source = "./modules/iam"
role_name = "${var.role_name}"
test_bucket = "${var.test_bucket}"
}
module "ec2_bastion" {
source = "./modules/ec2"
ec2_profile_name = "${var.bastion_profile_name}"
role_name = "${module.iam.name}"
ami = "${var.ami}"
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
subnet_id = "${aws_subnet.public_subnet.*.id[0]}"
vpc_security_group_ids = ["${aws_security_group.bastion_sg.id}"]
public_ip = "${var.bastion_public_ip_allow}"
disk_size = "${var.disk_size}"
command = "${data.template_file.script_file.rendered}"
tag_name = "${var.bastion_tag_name}"
}
module "ec2_web" {
source = "./modules/ec2"
ec2_profile_name = "${var.web_profile_name}"
role_name = "web-${module.iam.name}"
ami = "${var.ami}"
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
subnet_id = "${aws_subnet.private_subnet.*.id[0]}"
vpc_security_group_ids = ["${aws_security_group.web_sg.id}"]
public_ip = "${var.web_public_ip_allow}"
disk_size = "${var.disk_size}"
command = "${data.template_file.script_file.rendered}"
tag_name = "${var.web_tag_name}"
}