This repository was archived by the owner on Feb 17, 2021. It is now read-only.
forked from terraform-aws-modules/terraform-aws-autoscaling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
63 lines (55 loc) · 2.59 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
#######################
# Launch configuration
#######################
resource "aws_launch_configuration" "this" {
count = "${var.create_lc}"
name_prefix = "${coalesce(var.lc_name, var.name)}-"
image_id = "${var.image_id}"
instance_type = "${var.instance_type}"
iam_instance_profile = "${var.iam_instance_profile}"
key_name = "${var.key_name}"
security_groups = ["${var.security_groups}"]
associate_public_ip_address = "${var.associate_public_ip_address}"
user_data = "${var.user_data}"
enable_monitoring = "${var.enable_monitoring}"
#placement_tenancy = "${var.placement_tenancy}"
ebs_optimized = "${var.ebs_optimized}"
ebs_block_device = "${var.ebs_block_device}"
ephemeral_block_device = "${var.ephemeral_block_device}"
root_block_device = "${var.root_block_device}"
lifecycle {
create_before_destroy = true
}
spot_price = "${var.spot_price}" // placement_tenancy does not work with spot_price
}
####################
# Autoscaling group
####################
resource "aws_autoscaling_group" "this" {
count = "${var.create_asg}"
name_prefix = "${coalesce(var.asg_name, var.name)}-"
launch_configuration = "${var.create_lc ? element(aws_launch_configuration.this.*.name, 0) : var.launch_configuration}"
vpc_zone_identifier = ["${var.vpc_zone_identifier}"]
max_size = "${var.max_size}"
min_size = "${var.min_size}"
desired_capacity = "${var.desired_capacity}"
load_balancers = ["${var.load_balancers}"]
health_check_grace_period = "${var.health_check_grace_period}"
health_check_type = "${var.health_check_type}"
min_elb_capacity = "${var.min_elb_capacity}"
wait_for_elb_capacity = "${var.wait_for_elb_capacity}"
target_group_arns = ["${var.target_group_arns}"]
default_cooldown = "${var.default_cooldown}"
force_delete = "${var.force_delete}"
termination_policies = "${var.termination_policies}"
suspended_processes = "${var.suspended_processes}"
placement_group = "${var.placement_group}"
enabled_metrics = ["${var.enabled_metrics}"]
metrics_granularity = "${var.metrics_granularity}"
wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}"
protect_from_scale_in = "${var.protect_from_scale_in}"
tags = ["${concat(
list(map("key", "Name", "value", var.name, "propagate_at_launch", true)),
var.tags
)}"]
}