Skip to content

Instantly share code, notes, and snippets.

@yakaas
Created February 7, 2016 23:53
Show Gist options
  • Select an option

  • Save yakaas/6d2d1682d74d719a0304 to your computer and use it in GitHub Desktop.

Select an option

Save yakaas/6d2d1682d74d719a0304 to your computer and use it in GitHub Desktop.
resource "aws_ebs_volume" "elasticsearch_master" {
count = 3
availability_zone = "${lookup(var.azs, count.index)}"
size = 8
type = "gp2"
tags {
Name = "elasticsearch_master_az${count.index}.${var.env_name}"
}
}
resource "template_file" "elasticsearch_mount_vol_sh" {
filename = "${path.module}/elasticsearch_mount_vol.sh"
count = 3
vars {
volume_id = "${element(aws_ebs_volume.elasticsearch_master.*.id, count.index)}"
lsblk_name = "xvdf"
device_name = "/dev/xvdf"
mount_point = "/esvolume"
}
}
-----
resource "aws_instance" "elasticsearch_master" {
count = 3
...
user_data = <<SCRIPT
#!/bin/bash
# Attach and Mount ES EBS volume
${element(template_file.elasticsearch_mount_vol_sh.*.rendered, count.index)}
SCRIPT
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment