-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoscaling.tf
40 lines (37 loc) · 1.31 KB
/
autoscaling.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
resource "aws_launch_configuration" "bibleapi_launch_configuration" {
security_groups = [ "${aws_security_group.bibleapi_security_group.id}" ]
lifecycle { create_before_destroy = true }
instance_type = "t2.micro"
# http://cloud-images.ubuntu.com/locator/ec2/
image_id = "ami-41c12e23"
key_name = "administrator-key"
}
resource "aws_autoscaling_group" "autoscaling_group" {
name = "bibleapi-asg"
min_size = 1
max_size = 3
launch_configuration = "${aws_launch_configuration.bibleapi_launch_configuration.name}"
default_cooldown = 60
availability_zones = [ "${var.availability_zone_id}" ]
vpc_zone_identifier = [ "${var.subnet_id}" ]
tag {
key = "Name"
value = "bibleapi-autoscaling-group"
propagate_at_launch = true
}
lifecycle { create_before_destroy = true }
}
resource "aws_autoscaling_policy" "autoscale_group_policy_up_x1" {
name = "autoscale_group_policy_up_x1"
scaling_adjustment = 1
adjustment_type = "ChangeInCapacity"
cooldown = 60
autoscaling_group_name = "${aws_autoscaling_group.autoscaling_group.name}"
}
resource "aws_autoscaling_policy" "autoscale_group_policy_down_x1" {
name = "autoscale_group_policy_down_x1"
scaling_adjustment = -1
adjustment_type = "ChangeInCapacity"
cooldown = 60
autoscaling_group_name = "${aws_autoscaling_group.autoscaling_group.name}"
}