Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add autoscaling_group_tags variable to self-managed-node-groups #2084

Merged
Merged
6 changes: 6 additions & 0 deletions examples/self_managed_node_group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ module "eks" {

self_managed_node_group_defaults = {
create_security_group = false

# enable discovery of autoscaling groups by cluster-autoscaler
autoscaling_group_tags = {
"k8s.io/cluster-autoscaler/enabled" : true,
"k8s.io/cluster-autoscaler/${local.name}" : true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

self_managed_node_groups = {
Expand Down
1 change: 1 addition & 0 deletions modules/self-managed-node-group/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module "self_managed_node_group" {
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_ami_id"></a> [ami\_id](#input\_ami\_id) | The AMI from which to launch the instance | `string` | `""` | no |
| <a name="input_autoscaling_group_tags"></a> [autoscaling\_group\_tags](#input\_autoscaling\_group\_tags) | A map of additional tags to add to the auto\_scaling\_group created | `map(string)` | `{}` | no |
bryantbiggs marked this conversation as resolved.
Show resolved Hide resolved
| <a name="input_availability_zones"></a> [availability\_zones](#input\_availability\_zones) | A list of one or more availability zones for the group. Used for EC2-Classic and default subnets when not specified with `subnet_ids` argument. Conflicts with `subnet_ids` | `list(string)` | `null` | no |
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | Specify volumes to attach to the instance besides the volumes specified by the AMI | `any` | `{}` | no |
| <a name="input_bootstrap_extra_args"></a> [bootstrap\_extra\_args](#input\_bootstrap\_extra\_args) | Additional arguments passed to the bootstrap script. When `platform` = `bottlerocket`; these are additional [settings](https://github.com/bottlerocket-os/bottlerocket#settings) that are provided to the Bottlerocket user data | `string` | `""` | no |
Expand Down
10 changes: 10 additions & 0 deletions modules/self-managed-node-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,16 @@ resource "aws_autoscaling_group" "this" {
}
}

dynamic "tag" {
for_each = var.autoscaling_group_tags

content {
key = tag.key
value = tag.value
propagate_at_launch = false
}
}

timeouts {
delete = var.delete_timeout
}
Expand Down
6 changes: 6 additions & 0 deletions modules/self-managed-node-group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ variable "use_default_tags" {
default = false
}

variable "autoscaling_group_tags" {
description = "A map of additional tags to add to the auto_scaling_group created"
bryantbiggs marked this conversation as resolved.
Show resolved Hide resolved
type = map(string)
default = {}
}

################################################################################
# Autoscaling group schedule
################################################################################
Expand Down
5 changes: 3 additions & 2 deletions node_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,9 @@ module "self_managed_node_group" {
create_schedule = try(each.value.create_schedule, var.self_managed_node_group_defaults.create_schedule, false)
schedules = try(each.value.schedules, var.self_managed_node_group_defaults.schedules, null)

delete_timeout = try(each.value.delete_timeout, var.self_managed_node_group_defaults.delete_timeout, null)
use_default_tags = try(each.value.use_default_tags, var.self_managed_node_group_defaults.use_default_tags, false)
delete_timeout = try(each.value.delete_timeout, var.self_managed_node_group_defaults.delete_timeout, null)
use_default_tags = try(each.value.use_default_tags, var.self_managed_node_group_defaults.use_default_tags, false)
autoscaling_group_tags = try(each.value.autoscaling_group_tags, var.self_managed_node_group_defaults.autoscaling_group_tags, {})

# User data
platform = try(each.value.platform, var.self_managed_node_group_defaults.platform, "linux")
Expand Down