|
@@ -6,6 +6,25 @@ resource "aws_network_interface" "vmray-worker-interface" {
|
|
tags = merge(var.standard_tags, var.tags, { Name = "vmray-worker" })
|
|
tags = merge(var.standard_tags, var.tags, { Name = "vmray-worker" })
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+# Make /opt/vmray separate from the instance for greater margin of safety
|
|
|
|
+resource "aws_ebs_volume" "worker_opt_vmray" {
|
|
|
|
+ count = var.vmray_worker_instance_count
|
|
|
|
+ availability_zone = var.azs[count.index % 3]
|
|
|
|
+ size = var.vmray_worker_opt_vmray_size
|
|
|
|
+ type = "gp3"
|
|
|
|
+ encrypted = true
|
|
|
|
+ kms_key_id = data.aws_kms_key.ebs-key.arn
|
|
|
|
+
|
|
|
|
+ tags = merge(var.standard_tags, var.tags, { Name = "vmray-worker-${count.index}", Path = "/opt/vmray", Device = "/dev/xvdf" })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+resource "aws_volume_attachment" "worker_opt_vmray" {
|
|
|
|
+ count = var.vmray_worker_instance_count
|
|
|
|
+ device_name = "/dev/xvdf"
|
|
|
|
+ volume_id = aws_ebs_volume.worker_opt_vmray[count.index].id
|
|
|
|
+ instance_id = aws_instance.vmray-worker-instance[count.index].id
|
|
|
|
+}
|
|
|
|
+
|
|
resource "aws_instance" "vmray-worker-instance" {
|
|
resource "aws_instance" "vmray-worker-instance" {
|
|
count = var.vmray_worker_instance_count
|
|
count = var.vmray_worker_instance_count
|
|
tenancy = "default"
|
|
tenancy = "default"
|
|
@@ -31,6 +50,16 @@ resource "aws_instance" "vmray-worker-instance" {
|
|
kms_key_id = data.aws_kms_key.ebs-key.arn
|
|
kms_key_id = data.aws_kms_key.ebs-key.arn
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ebs_block_device {
|
|
|
|
+ # /opt/vmray
|
|
|
|
+ # Note: Not in AMI
|
|
|
|
+ device_name = "/dev/xvdf"
|
|
|
|
+ volume_size = var.vmray_worker_opt_vmray_size
|
|
|
|
+ delete_on_termination = true
|
|
|
|
+ encrypted = true
|
|
|
|
+ kms_key_id = data.aws_kms_key.ebs-key.arn
|
|
|
|
+ }
|
|
|
|
+
|
|
ebs_block_device {
|
|
ebs_block_device {
|
|
# swap
|
|
# swap
|
|
device_name = "/dev/xvdm"
|
|
device_name = "/dev/xvdm"
|
|
@@ -143,11 +172,12 @@ data "template_cloudinit_config" "cloud-init-vmray-worker" {
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
- # Additional parts as needed
|
|
|
|
- #part {
|
|
|
|
- # content_type = "text/x-shellscript"
|
|
|
|
- # content = "ffbaz"
|
|
|
|
- #}
|
|
|
|
|
|
+ # mount /dev/xvdf at /opt/vmray
|
|
|
|
+ part {
|
|
|
|
+ content_type = "text/cloud-boothook"
|
|
|
|
+ content = file("${path.module}/cloud-init/opt_vmray.boothook")
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
module "private_dns_record_vmray_worker" {
|
|
module "private_dns_record_vmray_worker" {
|