added market options to request spot instances without pools (#409)

* added market options to request spot instances without specifying pools in a launch template

* formatted

* simplified implementation

* formatted

* Update CHANGELOG.md
This commit is contained in:
Onur Sam
2019-07-23 16:33:16 +01:00
committed by Max Williams
parent ec64a74019
commit a95ad00b0a
3 changed files with 10 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
- Option to set a KMS key for the log group and encrypt it (by @till-krauss)
- Output the name of the cloudwatch log group (by @gbooth27)
- Option to use spot instances with launch templates without defining pools, especially useful for GPU instance types (@onur-sam-gtn-ai)
- Added `cpu_credits` param for the workers defined in `worker_groups_launch_template` (by @a-shink)
- Write your awesome addition here (by @you)

View File

@@ -81,6 +81,7 @@ locals {
spot_allocation_strategy = "lowest-price" # The only valid value is lowest-price, which is also the default value. The Auto Scaling group selects the cheapest Spot pools and evenly allocates your Spot capacity across the number of Spot pools that you specify.
spot_instance_pools = 10 # "Number of Spot pools per availability zone to allocate capacity. EC2 Auto Scaling selects the cheapest Spot pools and evenly allocates Spot capacity across the number of Spot pools that you specify."
spot_max_price = "" # Maximum price per unit hour that the user is willing to pay for the Spot instances. Default is the on-demand price
market_type = null # set to "spot" to use spot instances without defining pools
}
workers_group_defaults = merge(

View File

@@ -229,6 +229,14 @@ resource "aws_launch_template" "workers_launch_template" {
)
}
instance_market_options {
market_type = lookup(
var.worker_groups_launch_template[count.index],
"market_type",
local.workers_group_defaults["market_type"],
)
}
block_device_mappings {
device_name = lookup(
var.worker_groups_launch_template[count.index],