Skip to content

Commit

Permalink
feat: Add autoscaling_group_tags variable to self-managed-node-grou…
Browse files Browse the repository at this point in the history
…ps (#2084)

Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
  • Loading branch information
gferon and bryantbiggs authored Jun 2, 2022
1 parent 8178010 commit 8584dcb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
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}" : "owned",
}
}

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 autoscaling group created. Tags are applied to the autoscaling group only and are NOT propagated to instances | `map(string)` | `{}` | no |
| <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 autoscaling group created. Tags are applied to the autoscaling group only and are NOT propagated to instances"
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

0 comments on commit 8584dcb

Please sign in to comment.