-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
65 lines (51 loc) · 2.37 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
65
#######################
# Launch configuration
#######################
resource "aws_launch_configuration" "this" {
name_prefix = "${var.name}-"
image_id = "${length(var.image_id) > 0 ? var.image_id : data.aws_ami.ubuntu.id}"
instance_type = "${var.instance_type}"
iam_instance_profile = "${var.iam_instance_profile}"
key_name = "${var.key_name}"
security_groups = ["${var.security_groups}"]
user_data = "${var.user_data}"
enable_monitoring = "${var.is_live ? true : false}"
// placement_tenancy = "${var.placement_tenancy}"
// ebs_optimized = "${var.ebs_optimized}"
// ebs_block_device = "${var.ebs_block_device}"
// ephemeral_block_device = "${var.ephemeral_block_device}"
associate_public_ip_address = "${var.associate_public_ip_address}"
root_block_device = [{
volume_size = "${var.volume_size}"
volume_type = "gp2"
}]
lifecycle {
create_before_destroy = true
}
spot_price = "${var.spot_price}"
}
####################
# Autoscaling group
####################
resource "aws_autoscaling_group" "this" {
name = "${var.name}"
launch_configuration = "${aws_launch_configuration.this.name}"
vpc_zone_identifier = ["${var.subnet_ids}"]
max_size = "${var.max_size}"
min_size = "${var.min_size}"
load_balancers = ["${var.load_balancers}"]
target_group_arns = ["${var.target_group_arns}"]
health_check_grace_period = "${var.health_check_grace_period}"
health_check_type = "ELB"
// If we want to enable waiting for healthy instances (in terraform) for CI/CD?
// min_elb_capacity = "${var.min_elb_capacity}"
// wait_for_elb_capacity = "${var.wait_for_elb_capacity}"
// wait_for_capacity_timeout = "0"
// default_cooldown = "${var.default_cooldown}"
// force_delete = "${var.force_delete}"
termination_policies = ["OldestLaunchConfiguration", "OldestInstance"]
enabled_metrics = ["GroupInServiceInstances"]
// protect_from_scale_in = "${var.protect_from_scale_in}"
// placement_group = "${var.placement_group}"
tags = ["${var.tags}"]
}