# Make /opt/tqbackup separate from the instance for greater margin of safety resource "aws_ebs_volume" "tqbackup" { count = local.instance_count availability_zone = var.azs[count.index % 3] size = var.tqbackup_size type = "gp3" encrypted = true kms_key_id = data.aws_kms_key.ebs-key.arn # Can't have extra tags here, or terraform will flipflop between these and the instance's volume_tags #tags = merge(local.standard_tags, var.tags, { Name = "${local.server_name_stem}-${count.index}", Path = "/opt/tqbackup", Device = "/dev/xvdf" }) tags = merge(local.standard_tags, var.tags, { Name = "${local.server_name_stem}-${count.index}" }) } resource "aws_volume_attachment" "tqbackup" { count = local.instance_count device_name = "/dev/xvdf" volume_id = aws_ebs_volume.tqbackup[count.index].id instance_id = aws_instance.instance[count.index].id }