-
Notifications
You must be signed in to change notification settings - Fork 1
/
ec2.tf
45 lines (45 loc) · 1.89 KB
/
ec2.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
resource "aws_instance" "Bastion" {
ami = "${var.bastion["ami"]}"
instance_type = "${var.bastion["type"]}"
disable_api_termination = false
key_name = "${var.ec2_keypair}"
count = "${var.bastion["count"]}"
subnet_id = "${element(aws_subnet.PublicSubnet.*.id, count.index)}"
vpc_security_group_ids = ["${aws_security_group.bastion_sg.id}"]
#user_data = "${file("${path.cwd}/install-ansible.sh")}"
tags = {
Name = "bastion-${count.index}.${var.environment_tag}"
Environment = "${var.environment_tag}"
}
}
resource "aws_eip" "BastionPublicIP" {
count = "${var.bastion["count"]}"
instance = "${element(aws_instance.Bastion.*.id, count.index)}"
vpc = true
}
resource "aws_instance" "Master" {
ami = "${var.master["ami"]}"
instance_type = "${var.master["type"]}"
disable_api_termination = false
key_name = "${var.ec2_keypair}"
count = "${var.master["count"]}"
subnet_id = "${element(aws_subnet.PrivateSubnet.*.id, count.index)}"
vpc_security_group_ids = ["${aws_security_group.stack_sg.id}"]
tags = {
Name = "master-${count.index}.${var.environment_tag}"
Environment = "${var.environment_tag}"
}
}
resource "aws_instance" "Worker" {
ami = "${var.worker["ami"]}"
instance_type = "${var.worker["type"]}"
disable_api_termination = false
key_name = "${var.ec2_keypair}"
count = "${var.worker["count"]}"
subnet_id = "${element(aws_subnet.PrivateSubnet.*.id, count.index)}"
vpc_security_group_ids = ["${aws_security_group.stack_sg.id}"]
tags = {
Name = "worker-${count.index}.${var.environment_tag}"
Environment = "${var.environment_tag}"
}
}