-
Notifications
You must be signed in to change notification settings - Fork 0
/
hst.tf
executable file
·51 lines (41 loc) · 1.56 KB
/
hst.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
# User-data template
data "template_file" "userdata_hst" {
template = "${file("./files/userdata_hst.template")}"
vars {
# HostsReg
env_name = "${var.env_name}"
dns_zone = "${var.dns_zone}"
reg_token = "${var.reg_token}"
}
}
# Launch configuration
resource "aws_launch_configuration" "rancher_hst" {
image_id = "${lookup(var.ami_type, var.aws_region)}"
instance_type = "${var.hst_size}"
key_name = "${var.key_name}"
security_groups = ["${aws_security_group.hst.id}", "${aws_security_group.gocd.id}", "${aws_security_group.splunk.id}", "${aws_security_group.sonarqube.id}"]
iam_instance_profile = "${aws_iam_instance_profile.rancher.id}"
associate_public_ip_address = true
lifecycle {
create_before_destroy = true
}
user_data = "${data.template_file.userdata_hst.rendered}"
}
# Autoscaling group
resource "aws_autoscaling_group" "rancher_hst" {
name = "${var.env_name}-hst"
availability_zones = ["${var.pub_sub_a}"]
launch_configuration = "${aws_launch_configuration.rancher_hst.name}"
health_check_grace_period = 500
health_check_type = "EC2"
max_size = "${var.hst_max}"
min_size = "${var.hst_min}"
desired_capacity = "${var.hst_des}"
vpc_zone_identifier = ["${var.pub_sub_a}"]
tag {
key = "Name"
value = "${var.env_name}-hst"
propagate_at_launch = true
}
depends_on = ["aws_launch_configuration.rancher_hst"]
}