forked from hashicorp/terraform-aws-terraform-enterprise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprimary.tf
77 lines (62 loc) · 2.22 KB
/
primary.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
68
69
70
71
72
73
74
75
76
resource "aws_instance" "primary" {
# The number of primaries must be hard coded to 3 always for now.
# In the future we'll allow for different variables of primary, but it
# make sense to constrain the domain of problem related to primary counts
# for now.
count = 3
ami = var.ami != "" ? var.ami : local.distro_ami
instance_type = var.primary_instance_type
subnet_id = element(var.private_zone ? module.common.private_subnets : module.common.public_subnets, count.index)
vpc_security_group_ids = [
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
key_name = module.common.ssh_key_name
user_data = element(
data.template_cloudinit_config.config.*.rendered,
count.index,
)
root_block_device {
volume_type = "gp2"
volume_size = var.volume_size
}
tags = merge(
var.tags,
{
Name = "${var.prefix}-${module.common.install_id}:primary"
InstallationId = module.common.install_id
},
)
}
resource "aws_elb_attachment" "ptfe_app-primary" {
count = local.primary_count
elb = aws_elb.cluster_api.id
instance = element(aws_instance.primary.*.id, count.index)
}
resource "aws_elb_attachment" "ptfe_admin-primary" {
count = local.primary_count
elb = aws_elb.cluster_api.id
instance = element(aws_instance.primary.*.id, count.index)
}
resource "aws_elb_attachment" "cluster_api-primary" {
count = local.primary_count
elb = aws_elb.cluster_api.id
instance = element(aws_instance.primary.*.id, count.index)
}
resource "aws_elb_attachment" "cluster_assistant-primary" {
count = local.primary_count
elb = aws_elb.cluster_api.id
instance = element(aws_instance.primary.*.id, count.index)
}
resource "aws_lb_target_group_attachment" "admin-primary" {
count = local.primary_count
target_group_arn = module.lb.admin_group
target_id = aws_instance.primary[count.index].id
}
resource "aws_lb_target_group_attachment" "https-primary" {
count = local.primary_count
target_group_arn = module.lb.https_group
target_id = aws_instance.primary[count.index].id
}