diff --git a/main.tf b/main.tf index 46775f9..62c98ab 100644 --- a/main.tf +++ b/main.tf @@ -193,8 +193,10 @@ resource "aws_ebs_volume" "default" { } resource "aws_volume_attachment" "default" { - count = local.volume_count - device_name = var.ebs_device_name[count.index] - volume_id = aws_ebs_volume.default[count.index].id - instance_id = one(aws_instance.default[*].id) + count = local.volume_count + device_name = var.ebs_device_name[count.index] + volume_id = aws_ebs_volume.default[count.index].id + instance_id = one(aws_instance.default[*].id) + force_detach = var.force_detach_ebs + stop_instance_before_detaching = var.stop_ec2_before_detaching_vol } diff --git a/variables.tf b/variables.tf index afc63b4..3f81a7f 100644 --- a/variables.tf +++ b/variables.tf @@ -435,3 +435,15 @@ variable "external_network_interfaces" { description = "The external interface definitions to attach to the instances. This depends on the instance type" default = null } + +variable "force_detach_ebs" { + type = bool + default = false + description = "force the volume/s to detach from the instance." +} + +variable "stop_ec2_before_detaching_vol" { + type = bool + default = false + description = "Set this to true to ensure that the target instance is stopped before trying to detach the volume/s." +} \ No newline at end of file