Skip to content

Commit 2463381

Browse files
bryantbiggsspr-mweber3
authored andcommitted
feat: Allow configuring which tags are passed on launch template tag specifications (terraform-aws-modules#2360)
Resolves undefined
1 parent a878058 commit 2463381

File tree

7 files changed

+18
-2
lines changed

7 files changed

+18
-2
lines changed

modules/eks-managed-node-group/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ module "eks_managed_node_group" {
161161
| <a name="input_ram_disk_id"></a> [ram\_disk\_id](#input\_ram\_disk\_id) | The ID of the ram disk | `string` | `null` | no |
162162
| <a name="input_remote_access"></a> [remote\_access](#input\_remote\_access) | Configuration block with remote access settings. Only valid when `use_custom_launch_template` = `false` | `any` | `{}` | no |
163163
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | Identifiers of EC2 Subnets to associate with the EKS Node Group. These subnets must have the following resource tag: `kubernetes.io/cluster/CLUSTER_NAME` | `list(string)` | `null` | no |
164+
| <a name="input_tag_specifications"></a> [tag\_specifications](#input\_tag\_specifications) | The tags to apply to the resources during launch | `list(string)` | <pre>[<br> "instance",<br> "volume",<br> "network-interface",<br> "spot-instances-request"<br>]</pre> | no |
164165
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
165166
| <a name="input_taints"></a> [taints](#input\_taints) | The Kubernetes taints to be applied to the nodes in the node group. Maximum of 50 taints per node group | `any` | `{}` | no |
166167
| <a name="input_timeouts"></a> [timeouts](#input\_timeouts) | Create, update, and delete timeout configurations for the node group | `map(string)` | `{}` | no |

modules/eks-managed-node-group/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ resource "aws_launch_template" "this" {
278278
ram_disk_id = var.ram_disk_id
279279

280280
dynamic "tag_specifications" {
281-
for_each = toset(["instance", "volume", "elastic-gpu", "network-interface", "spot-instances-request"])
281+
for_each = toset(var.tag_specifications)
282282

283283
content {
284284
resource_type = tag_specifications.key

modules/eks-managed-node-group/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ variable "launch_template_tags" {
274274
default = {}
275275
}
276276

277+
variable "tag_specifications" {
278+
description = "The tags to apply to the resources during launch"
279+
type = list(string)
280+
default = ["instance", "volume", "network-interface", "spot-instances-request"]
281+
}
282+
277283
################################################################################
278284
# EKS Managed Node Group
279285
################################################################################

modules/self-managed-node-group/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ module "self_managed_node_group" {
161161
| <a name="input_service_linked_role_arn"></a> [service\_linked\_role\_arn](#input\_service\_linked\_role\_arn) | The ARN of the service-linked role that the ASG will use to call other AWS services | `string` | `null` | no |
162162
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | A list of subnet IDs to launch resources in. Subnets automatically determine which availability zones the group will reside. Conflicts with `availability_zones` | `list(string)` | `null` | no |
163163
| <a name="input_suspended_processes"></a> [suspended\_processes](#input\_suspended\_processes) | A list of processes to suspend for the Auto Scaling Group. The allowed values are `Launch`, `Terminate`, `HealthCheck`, `ReplaceUnhealthy`, `AZRebalance`, `AlarmNotification`, `ScheduledActions`, `AddToLoadBalancer`. Note that if you suspend either the `Launch` or `Terminate` process types, it can prevent your Auto Scaling Group from functioning properly | `list(string)` | `[]` | no |
164+
| <a name="input_tag_specifications"></a> [tag\_specifications](#input\_tag\_specifications) | The tags to apply to the resources during launch | `list(string)` | <pre>[<br> "instance",<br> "volume",<br> "network-interface",<br> "spot-instances-request"<br>]</pre> | no |
164165
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
165166
| <a name="input_target_group_arns"></a> [target\_group\_arns](#input\_target\_group\_arns) | A set of `aws_alb_target_group` ARNs, for use with Application or Network Load Balancing | `list(string)` | `[]` | no |
166167
| <a name="input_termination_policies"></a> [termination\_policies](#input\_termination\_policies) | A list of policies to decide how the instances in the Auto Scaling Group should be terminated. The allowed values are `OldestInstance`, `NewestInstance`, `OldestLaunchConfiguration`, `ClosestToNextInstanceHour`, `OldestLaunchTemplate`, `AllocationStrategy`, `Default` | `list(string)` | `[]` | no |

modules/self-managed-node-group/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ resource "aws_launch_template" "this" {
365365
ram_disk_id = var.ram_disk_id
366366

367367
dynamic "tag_specifications" {
368-
for_each = toset(["instance", "volume", "elastic-gpu", "network-interface", "spot-instances-request"])
368+
for_each = toset(var.tag_specifications)
369369

370370
content {
371371
resource_type = tag_specifications.key

modules/self-managed-node-group/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,12 @@ variable "launch_template_tags" {
286286
default = {}
287287
}
288288

289+
variable "tag_specifications" {
290+
description = "The tags to apply to the resources during launch"
291+
type = list(string)
292+
default = ["instance", "volume", "network-interface", "spot-instances-request"]
293+
}
294+
289295
################################################################################
290296
# Autoscaling group
291297
################################################################################

node_groups.tf

+2
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ module "eks_managed_node_group" {
297297
update_launch_template_default_version = try(each.value.update_launch_template_default_version, var.eks_managed_node_group_defaults.update_launch_template_default_version, true)
298298
launch_template_description = try(each.value.launch_template_description, var.eks_managed_node_group_defaults.launch_template_description, "Custom launch template for ${try(each.value.name, each.key)} EKS managed node group")
299299
launch_template_tags = try(each.value.launch_template_tags, var.eks_managed_node_group_defaults.launch_template_tags, {})
300+
tag_specifications = try(each.value.tag_specifications, var.eks_managed_node_group_defaults.tag_specifications, ["instance", "volume", "network-interface", "spot-instances-request"])
300301

301302
ebs_optimized = try(each.value.ebs_optimized, var.eks_managed_node_group_defaults.ebs_optimized, null)
302303
key_name = try(each.value.key_name, var.eks_managed_node_group_defaults.key_name, null)
@@ -422,6 +423,7 @@ module "self_managed_node_group" {
422423
update_launch_template_default_version = try(each.value.update_launch_template_default_version, var.self_managed_node_group_defaults.update_launch_template_default_version, true)
423424
launch_template_description = try(each.value.launch_template_description, var.self_managed_node_group_defaults.launch_template_description, "Custom launch template for ${try(each.value.name, each.key)} self managed node group")
424425
launch_template_tags = try(each.value.launch_template_tags, var.self_managed_node_group_defaults.launch_template_tags, {})
426+
tag_specifications = try(each.value.tag_specifications, var.eks_managed_node_group_defaults.tag_specifications, ["instance", "volume", "network-interface", "spot-instances-request"])
425427

426428
ebs_optimized = try(each.value.ebs_optimized, var.self_managed_node_group_defaults.ebs_optimized, null)
427429
ami_id = try(each.value.ami_id, var.self_managed_node_group_defaults.ami_id, "")

0 commit comments

Comments
 (0)