Skip to content

Commit 7409758

Browse files
authored
fix: allow forced ebs detachments or stopping instance before detachment (#212)
1 parent 8e754f8 commit 7409758

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

main.tf

+6-4
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ resource "aws_ebs_volume" "default" {
193193
}
194194

195195
resource "aws_volume_attachment" "default" {
196-
count = local.volume_count
197-
device_name = var.ebs_device_name[count.index]
198-
volume_id = aws_ebs_volume.default[count.index].id
199-
instance_id = one(aws_instance.default[*].id)
196+
count = local.volume_count
197+
device_name = var.ebs_device_name[count.index]
198+
volume_id = aws_ebs_volume.default[count.index].id
199+
instance_id = one(aws_instance.default[*].id)
200+
force_detach = var.force_detach_ebs
201+
stop_instance_before_detaching = var.stop_ec2_before_detaching_vol
200202
}

variables.tf

+12
Original file line numberDiff line numberDiff line change
@@ -435,3 +435,15 @@ variable "external_network_interfaces" {
435435
description = "The external interface definitions to attach to the instances. This depends on the instance type"
436436
default = null
437437
}
438+
439+
variable "force_detach_ebs" {
440+
type = bool
441+
default = false
442+
description = "force the volume/s to detach from the instance."
443+
}
444+
445+
variable "stop_ec2_before_detaching_vol" {
446+
type = bool
447+
default = false
448+
description = "Set this to true to ensure that the target instance is stopped before trying to detach the volume/s."
449+
}

0 commit comments

Comments
 (0)