forked from hashicorp/terraform-aws-terraform-enterprise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecondary.tf
68 lines (58 loc) · 1.86 KB
/
secondary.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
67
locals {
asg_tags = [
for item in keys(var.tags) :
map(
"key", item,
"value", element(values(var.tags), index(keys(var.tags), item)),
"propagate_at_launch", "true"
)
]
}
resource "aws_launch_configuration" "secondary" {
image_id = var.ami != "" ? var.ami : local.distro_ami
instance_type = local.rendered_secondary_instance_type
key_name = module.common.ssh_key_name
user_data = data.template_cloudinit_config.config_secondary.rendered
security_groups = [
module.lb.sg_lb_to_instance,
module.common.intra_vpc_ingress_and_egress_sg_id,
module.common.allow_ptfe_sg_id,
]
iam_instance_profile = aws_iam_instance_profile.ptfe.name
root_block_device {
volume_type = "gp2"
volume_size = var.volume_size
}
}
resource "aws_autoscaling_group" "secondary" {
# Interpolating the LC name into the ASG name here causes any changes that
# would replace the LC (like, most commonly, an AMI ID update) to _also_
# replace the ASG.
name = "${var.prefix}-lc-${aws_launch_configuration.secondary.name}"
launch_configuration = aws_launch_configuration.secondary.name
desired_capacity = var.secondary_count
min_size = var.secondary_count
max_size = var.secondary_count
vpc_zone_identifier = module.common.private_subnets
target_group_arns = [module.lb.https_group]
tags = concat(
[
{
key = "Name"
value = "${var.prefix}-${module.common.install_id}:secondary"
propagate_at_launch = true
},
{
key = "Hostname"
value = module.lb.endpoint
propagate_at_launch = true
},
{
key = "InstallationId"
value = module.common.install_id
propagate_at_launch = true
},
],
local.asg_tags
)
}