Skip to content

Commit

Permalink
Allow launch template spot instances without mixed policy (terraform-…
Browse files Browse the repository at this point in the history
…aws-modules#463)

* Add option to enable spot without MixedInstancePolicy

* Update docs
  • Loading branch information
TarekAS authored and max-rocket-internet committed Aug 6, 2019
1 parent c9986f5 commit fb71eaf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project adheres to [Semantic Versioning](http://semver.org/).

### Added

- Added `market_type` to `workers_launch_template.tf` allow the usage of spot nodegroups without mixed instances policy.
- Added support for log group tag in `./cluster.tf` (@lucas-giaco)
- Added support for workers iam role tag in `./workers.tf` (@lucas-giaco)
- Write your awesome addition here (by @you)
Expand Down
12 changes: 12 additions & 0 deletions docs/spot-instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ Launch Template support is a recent addition to both AWS and this module. It mig
kubelet_extra_args = "--node-labels=kubernetes.io/lifecycle=spot"
}
]
worker_groups_launch_template = [
{
name = "spot-2"
instance_type = "m4.xlarge"
asg_max_size = 5
asg_desired_size = 5
autoscaling_enabled = true
kubelet_extra_args = "--node-labels=kubernetes.io/lifecycle=spot"
market_type = "spot"
}
]
```

## Important issues
Expand Down
1 change: 1 addition & 0 deletions local.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ locals {
root_encrypted = "" # Whether the volume should be encrypted or not
eni_delete = true # Delete the ENI on termination (if set to false you will have to manually delete before destroying)
cpu_credits = "standard" # T2/T3 unlimited mode, can be 'standard' or 'unlimited'. Used 'standard' mode as default to avoid paying higher costs
market_type = null
# Settings for launch templates with mixed instances policy
override_instance_types = ["m5.large", "m5a.large", "m5d.large", "m5ad.large"] # A list of override instance types for mixed instances policy
on_demand_allocation_strategy = "prioritized" # Strategy to use when launching on-demand instances. Valid values: prioritized.
Expand Down
8 changes: 8 additions & 0 deletions workers_launch_template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ resource "aws_launch_template" "workers_launch_template" {
)
}

dynamic instance_market_options {
iterator = item
for_each = lookup(var.worker_groups_launch_template[count.index], "market_type", null) == null ? [] : list(lookup(var.worker_groups_launch_template[count.index], "market_type", null))
content {
market_type = item.value
}
}

block_device_mappings {
device_name = lookup(
var.worker_groups_launch_template[count.index],
Expand Down

0 comments on commit fb71eaf

Please sign in to comment.