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

fix: Set desired_capacity_type #3166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dtscssap
Copy link

@dtscssap dtscssap commented Sep 26, 2024

Description

  • sets the desired_capacity_type for the aws_autoscaling_group resource to AWS default value "units"

Motivation and Context

  • current implementation succeeds with leaving this attribute undefined which AWS will set to its default "units" on their end, but evidently subsequent runs of Terraform don't see this during a refresh of state
    • if a user goes into the AWS Console and edits the Autoscaling Group (changes nothing, just clicks the Save button), Terraform will suddenly see this attribute when it refreshes state 🤦

    • if this happens, you will have no choice but to destroy the autoscaling group and recreate via the Terraform because without this change there is no way to tell the current module to not try to set the desired_capacity_type = "units" -> null

        # module.eks_al2.module.self_managed_node_group["example"].aws_autoscaling_group.this will be updated in-place
        ~ resource "aws_autoscaling_group" "this" {
            - desired_capacity_type            = "units" -> null
              id                               = "example"
              name                             = "example"
              # (26 unchanged attributes hidden)
      
              # (39 unchanged blocks hidden)
          }
      
      Plan: 0 to add, 1 to change, 0 to destroy.
      
      Do you want to perform these actions?
        Terraform will perform the actions described above.
        Only 'yes' will be accepted to approve.
      
        Enter a value: yes
      
      module.eks_al2.module.self_managed_node_group["example"].aws_autoscaling_group.this: Modifying... [id=<redacted>]
      ╷
      │ Error: updating Auto Scaling Group (example): InvalidParameter: 1 validation error(s) found.
      │ - minimum field size of 1, UpdateAutoScalingGroupInput.DesiredCapacityType.
      │ 
      

Breaking Changes

  • no, "units" is the default value

How Has This Been Tested?

  • [ X ] I have updated at least one of the examples/* to demonstrate and validate my change(s)
    • I have not as there is nothing to show, this is a value that is being set under the hood
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@dtscssap dtscssap changed the title set desired_capacity_type fix: set desired_capacity_type Sep 26, 2024
@dtscssap dtscssap changed the title fix: set desired_capacity_type fix: Set desired_capacity_type Sep 26, 2024
@dtscssap dtscssap changed the title fix: Set desired_capacity_type fix: Set desired_capacity_type Sep 26, 2024
@@ -497,6 +497,7 @@ resource "aws_autoscaling_group" "this" {
default_cooldown = var.default_cooldown
default_instance_warmup = var.default_instance_warmup
desired_capacity = var.desired_size
desired_capacity_type = "units"
Copy link

Choose a reason for hiding this comment

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

Please create var.desired_capacity_type and make "units" as a default value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants