This repository has been archived by the owner on Apr 22, 2022. It is now read-only.
forked from Kgirthofer/ecs_cluster_terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoscaling.tf
67 lines (61 loc) · 2.12 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
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
66
#
# AutoScaling resources
#
resource "aws_launch_configuration" "container_instance" {
lifecycle {
create_before_destroy = true
}
root_block_device {
volume_type = "${var.root_block_device_type}"
volume_size = "${var.root_block_device_size}"
encrypted = "${var.root_block_device_encrypted}"
}
iam_instance_profile = "${aws_iam_instance_profile.container_instance.name}"
image_id = "${var.ami_id}"
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
security_groups = var.security_groups
user_data = templatefile("${path.module}/cloud-config/base-container-instance.yml.tpl", {
ecs_cluster_name = aws_ecs_cluster.container_instance.name
cloud_config = var.cloud_config
})
}
resource "aws_autoscaling_group" "container_instance" {
name = "asg${var.environment}${var.project}ContainerInstance"
launch_configuration = "${aws_launch_configuration.container_instance.name}"
health_check_grace_period = "${var.health_check_grace_period}"
health_check_type = "EC2"
desired_capacity = "${var.desired_capacity}"
termination_policies = ["OldestLaunchConfiguration", "Default"]
min_size = "${var.min_size}"
max_size = "${var.max_size}"
enabled_metrics = "${var.enabled_metrics}"
vpc_zone_identifier = "${var.private_subnet_ids}"
tags = [
{
key = "Name"
value = "${var.environment}-${var.project}-ContainerInstance"
propagate_at_launch = true
},
{
key = "Project"
value = "${var.project}"
propagate_at_launch = true
},
{
key = "Environment"
value = "${var.environment}"
propagate_at_launch = true
},
{
key = "Managed By"
value = "Terraform"
propagate_at_launch = true
},
{
key = "Inspector Scan"
value = "${var.inspector_scanned}"
propagate_at_launch = true
}
]
}