diff --git a/CHANGELOG.md b/CHANGELOG.md index 03cd0a1..ad9eb3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/local.tf b/local.tf index 8cf58fd..e2f8b3a 100644 --- a/local.tf +++ b/local.tf @@ -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( diff --git a/workers_launch_template.tf b/workers_launch_template.tf index b57f4e6..caee563 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -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],