backup_ebs.tf 932 B

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