-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbluedata_infra_main_worker.tf
98 lines (82 loc) · 2.78 KB
/
bluedata_infra_main_worker.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
resource "aws_instance" "workers" {
count = var.worker_count
ami = var.EC2_CENTOS7_AMIS[var.region]
instance_type = var.wkr_instance_types != null ? var.wkr_instance_types[count.index] : var.wkr_instance_type
key_name = aws_key_pair.main.key_name
vpc_security_group_ids = [
module.network.security_group_allow_all_from_client_ip,
module.network.security_group_main_id
]
subnet_id = module.network.subnet_main_id
root_block_device {
volume_type = "gp2"
volume_size = 400
tags = {
Name = "${var.project_id}-worker-${count.index + 1}-root-ebs"
Project = var.project_id
user = local.user
deployment_uuid = random_uuid.deployment_uuid.result
}
}
tags = {
Name = "${var.project_id}-worker-${count.index + 1}"
Project = var.project_id
user = local.user
deployment_uuid = random_uuid.deployment_uuid.result
}
}
resource "null_resource" "yum_update_workers" {
count = var.worker_count
connection {
type = "ssh"
user = "centos"
host = aws_instance.workers.*.public_ip[count.index]
private_key = file(var.ssh_prv_key_path)
agent = false
}
provisioner "remote-exec" {
inline = [ "sudo yum update -y -q" ]
}
}
# /dev/sdb
resource "aws_ebs_volume" "worker-ebs-volumes-sdb" {
count = var.worker_count
availability_zone = var.az
size = 500
type = "gp2"
tags = {
Name = "${var.project_id}-worker-${count.index + 1}-ebs-sdb"
Project = var.project_id
user = local.user
deployment_uuid = random_uuid.deployment_uuid.result
}
}
resource "aws_volume_attachment" "worker-volume-attachment-sdb" {
count = var.worker_count
device_name = "/dev/sdb"
volume_id = aws_ebs_volume.worker-ebs-volumes-sdb.*.id[count.index]
instance_id = aws_instance.workers.*.id[count.index]
# hack to allow `terraform destroy ...` to work: https://github.com/hashicorp/terraform/issues/2957
force_detach = true
}
# /dev/sdc
resource "aws_ebs_volume" "worker-ebs-volumes-sdc" {
count = var.worker_count
availability_zone = var.az
size = 500
type = "gp2"
tags = {
Name = "${var.project_id}-worker-${count.index + 1}-ebs-sdc"
Project = var.project_id
user = local.user
deployment_uuid = random_uuid.deployment_uuid.result
}
}
resource "aws_volume_attachment" "worker-volume-attachment-sdc" {
count = var.worker_count
device_name = "/dev/sdc"
volume_id = aws_ebs_volume.worker-ebs-volumes-sdc.*.id[count.index]
instance_id = aws_instance.workers.*.id[count.index]
# hack to allow `terraform destroy ...` to work: https://github.com/hashicorp/terraform/issues/2957
force_detach = true
}