Skip to content

Commit 1892b1e

Browse files
authored
fix: Update autoscaling group tags -> tag to support v4 of AWS provider (#1866)
1 parent 432c485 commit 1892b1e

File tree

5 files changed

+23
-55
lines changed

5 files changed

+23
-55
lines changed

examples/irsa_autoscale_refresh/main.tf

+3-16
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ module "eks" {
5454
triggers = ["tag"]
5555
}
5656

57-
propogate_tags = [{
58-
key = "aws-node-termination-handler/managed"
59-
value = true
60-
propagate_at_launch = true
61-
}]
57+
tags = { "aws-node-termination-handler/managed" = "true" }
6258
}
6359

6460
mixed_instance = {
@@ -82,11 +78,7 @@ module "eks" {
8278
]
8379
}
8480

85-
propogate_tags = [{
86-
key = "aws-node-termination-handler/managed"
87-
value = true
88-
propagate_at_launch = true
89-
}]
81+
tags = { "aws-node-termination-handler/managed" = "true" }
9082
}
9183

9284
spot = {
@@ -96,12 +88,7 @@ module "eks" {
9688
}
9789

9890
bootstrap_extra_args = "--kubelet-extra-args '--node-labels=node.kubernetes.io/lifecycle=spot'"
99-
100-
propogate_tags = [{
101-
key = "aws-node-termination-handler/managed"
102-
value = true
103-
propagate_at_launch = true
104-
}]
91+
tags = { "aws-node-termination-handler/managed" = "true" }
10592
}
10693
}
10794

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module "self_managed_node_group" {
8585
| <a name="input_cluster_auth_base64"></a> [cluster\_auth\_base64](#input\_cluster\_auth\_base64) | Base64 encoded CA of associated EKS cluster | `string` | `""` | no |
8686
| <a name="input_cluster_endpoint"></a> [cluster\_endpoint](#input\_cluster\_endpoint) | Endpoint of associated EKS cluster | `string` | `""` | no |
8787
| <a name="input_cluster_ip_family"></a> [cluster\_ip\_family](#input\_cluster\_ip\_family) | The IP family used to assign Kubernetes pod and service addresses. Valid values are `ipv4` (default) and `ipv6` | `string` | `null` | no |
88-
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of associated EKS cluster | `string` | `null` | no |
88+
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of associated EKS cluster | `string` | `""` | no |
8989
| <a name="input_cluster_security_group_id"></a> [cluster\_security\_group\_id](#input\_cluster\_security\_group\_id) | Cluster control plane security group ID | `string` | `null` | no |
9090
| <a name="input_cluster_version"></a> [cluster\_version](#input\_cluster\_version) | Kubernetes cluster version - used to lookup default AMI ID if one is not provided | `string` | `null` | no |
9191
| <a name="input_cpu_options"></a> [cpu\_options](#input\_cpu\_options) | The CPU options for the instance | `map(string)` | `null` | no |
@@ -146,7 +146,6 @@ module "self_managed_node_group" {
146146
| <a name="input_platform"></a> [platform](#input\_platform) | Identifies if the OS platform is `bottlerocket`, `linux`, or `windows` based | `string` | `"linux"` | no |
147147
| <a name="input_post_bootstrap_user_data"></a> [post\_bootstrap\_user\_data](#input\_post\_bootstrap\_user\_data) | User data that is appended to the user data script after of the EKS bootstrap script. Not used when `platform` = `bottlerocket` | `string` | `""` | no |
148148
| <a name="input_pre_bootstrap_user_data"></a> [pre\_bootstrap\_user\_data](#input\_pre\_bootstrap\_user\_data) | User data that is injected into the user data script ahead of the EKS bootstrap script. Not used when `platform` = `bottlerocket` | `string` | `""` | no |
149-
| <a name="input_propagate_tags"></a> [propagate\_tags](#input\_propagate\_tags) | A list of tag blocks. Each element should have keys named `key`, `value`, and `propagate_at_launch` | `list(map(string))` | `[]` | no |
150149
| <a name="input_protect_from_scale_in"></a> [protect\_from\_scale\_in](#input\_protect\_from\_scale\_in) | Allows setting instance protection. The autoscaling group will not select instances with this setting for termination during scale in events. | `bool` | `false` | no |
151150
| <a name="input_ram_disk_id"></a> [ram\_disk\_id](#input\_ram\_disk\_id) | The ID of the ram disk | `string` | `null` | no |
152151
| <a name="input_schedules"></a> [schedules](#input\_schedules) | Map of autoscaling group schedule to create | `map(any)` | `{}` | no |

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

+17-28
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,23 @@ resource "aws_autoscaling_group" "this" {
378378
}
379379
}
380380

381+
dynamic "tag" {
382+
for_each = merge(
383+
{
384+
"Name" = var.name
385+
"kubernetes.io/cluster/${var.cluster_name}" = "owned"
386+
"k8s.io/cluster/${var.cluster_name}" = "owned"
387+
},
388+
var.tags,
389+
)
390+
391+
content {
392+
key = tag.key
393+
value = tag.value
394+
propagate_at_launch = true
395+
}
396+
}
397+
381398
timeouts {
382399
delete = var.delete_timeout
383400
}
@@ -388,34 +405,6 @@ resource "aws_autoscaling_group" "this" {
388405
desired_capacity
389406
]
390407
}
391-
392-
tags = concat(
393-
[
394-
{
395-
key = "Name"
396-
value = var.name
397-
propagate_at_launch = true
398-
},
399-
{
400-
key = "kubernetes.io/cluster/${var.cluster_name}"
401-
value = "owned"
402-
propagate_at_launch = true
403-
},
404-
{
405-
key = "k8s.io/cluster/${var.cluster_name}"
406-
value = "owned"
407-
propagate_at_launch = true
408-
},
409-
],
410-
var.propagate_tags,
411-
[for k, v in var.tags :
412-
{
413-
key = k
414-
value = v
415-
propagate_at_launch = true
416-
}
417-
]
418-
)
419408
}
420409

421410
################################################################################

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ variable "platform" {
2323
variable "cluster_name" {
2424
description = "Name of associated EKS cluster"
2525
type = string
26-
default = null
26+
default = ""
2727
}
2828

2929
variable "cluster_endpoint" {
@@ -446,12 +446,6 @@ variable "delete_timeout" {
446446
default = null
447447
}
448448

449-
variable "propagate_tags" {
450-
description = "A list of tag blocks. Each element should have keys named `key`, `value`, and `propagate_at_launch`"
451-
type = list(map(string))
452-
default = []
453-
}
454-
455449
################################################################################
456450
# Autoscaling group schedule
457451
################################################################################

node_groups.tf

+1-2
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,5 @@ module "self_managed_node_group" {
450450
security_group_rules = try(each.value.security_group_rules, var.self_managed_node_group_defaults.security_group_rules, {})
451451
security_group_tags = try(each.value.security_group_tags, var.self_managed_node_group_defaults.security_group_tags, {})
452452

453-
tags = merge(var.tags, try(each.value.tags, var.self_managed_node_group_defaults.tags, {}))
454-
propagate_tags = try(each.value.propagate_tags, var.self_managed_node_group_defaults.propagate_tags, [])
453+
tags = merge(var.tags, try(each.value.tags, var.self_managed_node_group_defaults.tags, {}))
455454
}

0 commit comments

Comments
 (0)