Skip to content

Commit 1c0f892

Browse files
authored
Merge branch 'main' into feature/spot-instance-enablement
2 parents b6ae4ad + 0572cc3 commit 1c0f892

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ Available targets:
245245
| <a name="input_evaluation_periods"></a> [evaluation\_periods](#input\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold. | `number` | `5` | no |
246246
| <a name="input_external_network_interface_enabled"></a> [external\_network\_interface\_enabled](#input\_external\_network\_interface\_enabled) | Wheter to attach an external ENI as the eth0 interface for the instance. Any change to the interface will force instance recreation. | `bool` | `false` | no |
247247
| <a name="input_external_network_interfaces"></a> [external\_network\_interfaces](#input\_external\_network\_interfaces) | The external interface definitions to attach to the instances. This depends on the instance type | <pre>list(object({<br/> delete_on_termination = bool<br/> device_index = number<br/> network_card_index = number<br/> network_interface_id = string<br/> }))</pre> | `null` | no |
248+
| <a name="input_force_detach_ebs"></a> [force\_detach\_ebs](#input\_force\_detach\_ebs) | force the volume/s to detach from the instance. | `bool` | `false` | no |
248249
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br/>Set to `0` for unlimited length.<br/>Set to `null` for keep the existing setting, which defaults to `0`.<br/>Does not affect `id_full`. | `number` | `null` | no |
249250
| <a name="input_instance_initiated_shutdown_behavior"></a> [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Specifies whether an instance stops or terminates when you initiate shutdown from the instance. Can be one of 'stop' or 'terminate'. | `string` | `null` | no |
250251
| <a name="input_instance_market_options"></a> [instance\_market\_options](#input\_instance\_market\_options) | Describes the market (purchasing) option for the instances.<br/>See [docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#spot-options) for more information. | <pre>object({<br/> market_type = string<br/> spot_options = optional(object({<br/> instance_interruption_behavior = optional(string)<br/> max_price = optional(number)<br/> spot_instance_type = optional(string)<br/> valid_until = optional(string)<br/> }))<br/> })</pre> | `null` | no |
@@ -292,6 +293,7 @@ Available targets:
292293
| <a name="input_ssm_patch_manager_s3_log_bucket"></a> [ssm\_patch\_manager\_s3\_log\_bucket](#input\_ssm\_patch\_manager\_s3\_log\_bucket) | The name of the s3 bucket to export the patch log to | `string` | `null` | no |
293294
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
294295
| <a name="input_statistic_level"></a> [statistic\_level](#input\_statistic\_level) | The statistic to apply to the alarm's associated metric. Allowed values are: SampleCount, Average, Sum, Minimum, Maximum | `string` | `"Maximum"` | no |
296+
| <a name="input_stop_ec2_before_detaching_vol"></a> [stop\_ec2\_before\_detaching\_vol](#input\_stop\_ec2\_before\_detaching\_vol) | Set this to true to ensure that the target instance is stopped before trying to detach the volume/s. | `bool` | `false` | no |
295297
| <a name="input_subnet"></a> [subnet](#input\_subnet) | VPC Subnet ID the instance is launched in | `string` | n/a | yes |
296298
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br/>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
297299
| <a name="input_tenancy"></a> [tenancy](#input\_tenancy) | Tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of 'dedicated' runs on single-tenant hardware. The 'host' tenancy is not supported for the import-instance command. Valid values are 'default', 'dedicated', and 'host'. | `string` | `"default"` | no |

main.tf

+6-4
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@ resource "aws_ebs_volume" "default" {
211211
}
212212

213213
resource "aws_volume_attachment" "default" {
214-
count = local.volume_count
215-
device_name = var.ebs_device_name[count.index]
216-
volume_id = aws_ebs_volume.default[count.index].id
217-
instance_id = one(aws_instance.default[*].id)
214+
count = local.volume_count
215+
device_name = var.ebs_device_name[count.index]
216+
volume_id = aws_ebs_volume.default[count.index].id
217+
instance_id = one(aws_instance.default[*].id)
218+
force_detach = var.force_detach_ebs
219+
stop_instance_before_detaching = var.stop_ec2_before_detaching_vol
218220
}

variables.tf

+12
Original file line numberDiff line numberDiff line change
@@ -456,3 +456,15 @@ variable "external_network_interfaces" {
456456
description = "The external interface definitions to attach to the instances. This depends on the instance type"
457457
default = null
458458
}
459+
460+
variable "force_detach_ebs" {
461+
type = bool
462+
default = false
463+
description = "force the volume/s to detach from the instance."
464+
}
465+
466+
variable "stop_ec2_before_detaching_vol" {
467+
type = bool
468+
default = false
469+
description = "Set this to true to ensure that the target instance is stopped before trying to detach the volume/s."
470+
}

0 commit comments

Comments
 (0)