-
Notifications
You must be signed in to change notification settings - Fork 1
/
aws_servers.tf
40 lines (35 loc) · 1.31 KB
/
aws_servers.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
# Terraform definition for the lab servers
#
data "template_file" "server_userdata" {
count = "${var.server_count}"
template = "${file("${path.module}/userdata/server.userdata")}"
vars {
hostname = "${var.id}-server${count.index + 1}"
jump_ip = "${aws_instance.jump.private_ip}"
number = "${count.index + 1}"
}
}
resource "aws_instance" "server" {
count = "${var.server_count}"
ami = "${lookup(var.ami_centos, var.aws_region)}"
availability_zone = "${lookup(var.aws_az, var.aws_region)}"
instance_type = "${var.flavour_centos}"
key_name = "${var.key}"
vpc_security_group_ids = ["${aws_security_group.jumpsg.id}"]
subnet_id = "${aws_subnet.privnet.id}"
private_ip = "${format("%s%02d", var.base_ip, count.index + 1)}"
source_dest_check = false
user_data = "${data.template_file.server_userdata.*.rendered[count.index]}"
depends_on = ["aws_instance.jump"]
tags {
Name = "${var.id}-server${count.index + 1}"
Owner = "${var.owner}"
Lab_Group = "servers"
Lab_Name = "server${count.index + 1}.lab"
}
root_block_device {
volume_type = "standard"
volume_size = "${var.vol_size_centos}"
delete_on_termination = "true"
}
}