From 34b74518e8e996b4a54c1fc2975eac5f66feceee Mon Sep 17 00:00:00 2001 From: Alexander Shinkarenko Date: Fri, 12 Jul 2019 19:44:54 +0700 Subject: [PATCH] Configure 'cpu_credits' for workers (#253) (#426) * Configure 'cpu_credits' for workers (#253) * Updated CHANGELOG(#253) * Moved default to settings for launch templates(#253) --- CHANGELOG.md | 1 + local.tf | 1 + workers_launch_template.tf | 8 ++++++++ workers_launch_template_mixed.tf | 8 ++++++++ 4 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62d9ffc..03cd0a1 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) + - Added `cpu_credits` param for the workers defined in `worker_groups_launch_template` (by @a-shink) - Write your awesome addition here (by @you) ### Changed diff --git a/local.tf b/local.tf index 6caea57..8cf58fd 100644 --- a/local.tf +++ b/local.tf @@ -72,6 +72,7 @@ locals { launch_template_placement_group = "" # The name of the placement group into which to launch the instances, if any. 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 # 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. diff --git a/workers_launch_template.tf b/workers_launch_template.tf index 931c18c..b57f4e6 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -200,6 +200,14 @@ resource "aws_launch_template" "workers_launch_template" { ), ) + credit_specification { + cpu_credits = lookup( + var.worker_groups_launch_template[count.index], + "cpu_credits", + local.workers_group_defaults["cpu_credits"] + ) + } + monitoring { enabled = lookup( var.worker_groups_launch_template[count.index], diff --git a/workers_launch_template_mixed.tf b/workers_launch_template_mixed.tf index 7de2c9a..7dd9d90 100644 --- a/workers_launch_template_mixed.tf +++ b/workers_launch_template_mixed.tf @@ -250,6 +250,14 @@ resource "aws_launch_template" "workers_launch_template_mixed" { ), ) + credit_specification { + cpu_credits = lookup( + var.worker_groups_launch_template_mixed[count.index], + "cpu_credits", + local.workers_group_defaults["cpu_credits"] + ) + } + monitoring { enabled = lookup( var.worker_groups_launch_template_mixed[count.index],