Skip to content

Commit 05b91a6

Browse files
committed
feat(aws_instance): add instance market options block
1 parent 7cf5297 commit 05b91a6

File tree

8 files changed

+6
-23
lines changed

8 files changed

+6
-23
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ Available targets:
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 |
248248
| <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 |
249249
| <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 |
250-
| <a name="input_instance_market_options_enabled"></a> [instance\_market\_options\_enabled](#input\_instance\_market\_options\_enabled) | Wheter to enable the purchasing option for the instances | `bool` | `false` | no |
251250
| <a name="input_instance_profile"></a> [instance\_profile](#input\_instance\_profile) | A pre-defined profile to attach to the instance (default is to build our own) | `string` | `""` | no |
252251
| <a name="input_instance_profile_enabled"></a> [instance\_profile\_enabled](#input\_instance\_profile\_enabled) | Whether an IAM instance profile is created to pass a role to an Amazon EC2 instance when the instance starts | `bool` | `true` | no |
253252
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The type of the instance | `string` | `"t2.micro"` | no |
@@ -327,7 +326,7 @@ Available targets:
327326
| <a name="output_security_group_id"></a> [security\_group\_id](#output\_security\_group\_id) | EC2 instance Security Group ID |
328327
| <a name="output_security_group_ids"></a> [security\_group\_ids](#output\_security\_group\_ids) | IDs on the AWS Security Groups associated with the instance |
329328
| <a name="output_security_group_name"></a> [security\_group\_name](#output\_security\_group\_name) | EC2 instance Security Group name |
330-
| <a name="output_spot_instance_request_id"></a> [spot\_instance\_request\_id](#output\_spot\_instance\_request\_id) | the ID of the Spot Instance request |
329+
| <a name="output_spot_instance_request_id"></a> [spot\_instance\_request\_id](#output\_spot\_instance\_request\_id) | ID of the Spot Instance request |
331330
| <a name="output_ssh_key_pair"></a> [ssh\_key\_pair](#output\_ssh\_key\_pair) | Name of the SSH key pair provisioned on the instance |
332331
<!-- markdownlint-restore -->
333332

docs/terraform.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
| <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 |
8989
| <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 |
9090
| <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 |
91-
| <a name="input_instance_market_options_enabled"></a> [instance\_market\_options\_enabled](#input\_instance\_market\_options\_enabled) | Wheter to enable the purchasing option for the instances | `bool` | `false` | no |
9291
| <a name="input_instance_profile"></a> [instance\_profile](#input\_instance\_profile) | A pre-defined profile to attach to the instance (default is to build our own) | `string` | `""` | no |
9392
| <a name="input_instance_profile_enabled"></a> [instance\_profile\_enabled](#input\_instance\_profile\_enabled) | Whether an IAM instance profile is created to pass a role to an Amazon EC2 instance when the instance starts | `bool` | `true` | no |
9493
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The type of the instance | `string` | `"t2.micro"` | no |
@@ -168,6 +167,6 @@
168167
| <a name="output_security_group_id"></a> [security\_group\_id](#output\_security\_group\_id) | EC2 instance Security Group ID |
169168
| <a name="output_security_group_ids"></a> [security\_group\_ids](#output\_security\_group\_ids) | IDs on the AWS Security Groups associated with the instance |
170169
| <a name="output_security_group_name"></a> [security\_group\_name](#output\_security\_group\_name) | EC2 instance Security Group name |
171-
| <a name="output_spot_instance_request_id"></a> [spot\_instance\_request\_id](#output\_spot\_instance\_request\_id) | the ID of the Spot Instance request |
170+
| <a name="output_spot_instance_request_id"></a> [spot\_instance\_request\_id](#output\_spot\_instance\_request\_id) | ID of the Spot Instance request |
172171
| <a name="output_ssh_key_pair"></a> [ssh\_key\_pair](#output\_ssh\_key\_pair) | Name of the SSH key pair provisioned on the instance |
173172
<!-- markdownlint-restore -->

examples/complete/fixtures.us-east-2.spot.tfvars

-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ ssh_public_key_path = "/secrets"
5858

5959
metric_treat_missing_data = "notBreaching"
6060

61-
instance_market_options_enabled = true
62-
6361
market_type = "spot"
6462

6563
spot_options_attributes = [{

examples/complete/main.tf

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ module "ec2_instance" {
8686
instance_profile = aws_iam_instance_profile.test.name
8787
tenancy = var.tenancy
8888
metric_treat_missing_data = var.metric_treat_missing_data
89-
instance_market_options_enabled = var.instance_market_options_enabled
9089
market_type = var.market_type
9190
spot_options_attributes = var.spot_options_attributes
9291

examples/complete/outputs.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ output "security_group_name" {
114114
}
115115

116116
output "instance_lifecycle" {
117-
value = var.instance_market_options_enabled ? module.ec2_instance.instance_lifecycle : null
117+
value = var.spot_options_attributes != [] ? module.ec2_instance.instance_lifecycle : null
118118
description = "Indicates whether this is a Spot Instance or a Scheduled Instance"
119119
}
120120

121121
output "spot_instance_request_id" {
122-
value = var.instance_market_options_enabled && var.market_type == "spot" ? module.ec2_instance.spot_instance_request_id : null
122+
value = var.spot_options_attributes != [] && var.market_type == "spot" ? module.ec2_instance.spot_instance_request_id : null
123123
description = "the ID of the Spot Instance request"
124124
}

examples/complete/variables.tf

-6
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ variable "metric_treat_missing_data" {
5757
}
5858
}
5959

60-
variable "instance_market_options_enabled" {
61-
type = bool
62-
description = "Wheter to enable the purchasing option for the instances"
63-
default = false
64-
}
65-
6660
variable "market_type" {
6761
type = string
6862
description = "(Optional) Type of market for the instance. Valid values are `spot` and `capacity-block`. Defaults to `spot`. Required if a non-empty value is provided for `spot_options_attributes`."

outputs.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ output "security_group_name" {
102102
}
103103

104104
output "instance_lifecycle" {
105-
value = var.instance_market_options_enabled ? aws_instance.default[*].instance_lifecycle : null
105+
value = var.spot_options_attributes != [] ? aws_instance.default[*].instance_lifecycle : null
106106
description = "Indicates whether this is a Spot Instance or a Scheduled Instance"
107107
}
108108

109109
output "spot_instance_request_id" {
110-
value = var.instance_market_options_enabled && var.market_type == "spot" ? aws_instance.default[*].spot_instance_request_id : null
110+
value = var.spot_options_attributes != [] && var.market_type == "spot" ? aws_instance.default[*].spot_instance_request_id : null
111111
description = "ID of the Spot Instance request"
112112
}

variables.tf

-6
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ variable "burstable_mode" {
4646
default = null
4747
}
4848

49-
variable "instance_market_options_enabled" {
50-
type = bool
51-
description = "Whether to enable the purchasing option for the instances"
52-
default = false
53-
}
54-
5549
variable "market_type" {
5650
type = string
5751
description = "Type of market for the instance. Valid values are `spot` and `capacity-block`. Defaults to `spot`. Required if a non-empty value is provided for `spot_options_attributes`."

0 commit comments

Comments
 (0)