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

[Bug]: changes to initial_lifecycle_hook block of ASG does not force replacement #34178

Closed
dhrkumar opened this issue Oct 31, 2023 · 3 comments · Fixed by #34260
Closed

[Bug]: changes to initial_lifecycle_hook block of ASG does not force replacement #34178

dhrkumar opened this issue Oct 31, 2023 · 3 comments · Fixed by #34260
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service.
Milestone

Comments

@dhrkumar
Copy link
Contributor

Terraform Core Version

1.3.6

AWS Provider Version

5.23.1

Affected Resource(s)

  • aws_autoscaling_group

Expected Behavior

When attempting to update initial_lifecycle_hook attribute like heartbeat_timeout in an auto scaling group, I would expect that aws_autoscaling_group to be replaced, as to apply expected hook configuration.

Actual Behavior

Terraform plan produces an inline update for aws_autoscaling_group with creating a new hook and deleting old hook, which actually does nothing as the hook block is only intended for create phase of ASG.

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_autoscaling_group.asg will be updated in-place
  ~ resource "aws_autoscaling_group" "asg" {
        id                               = "terraform-20231031112905745500000001"
        name                             = "terraform-20231031112905745500000001"
        # (27 unchanged attributes hidden)

      - initial_lifecycle_hook {
          - default_result       = "CONTINUE" -> null
          - heartbeat_timeout    = 30 -> null
          - lifecycle_transition = "autoscaling:EC2_INSTANCE_LAUNCHING" -> null
          - name                 = "lifecycle-hook-update-test" -> null
        }
      + initial_lifecycle_hook {
          + default_result       = "CONTINUE"
          + heartbeat_timeout    = 40
          + lifecycle_transition = "autoscaling:EC2_INSTANCE_LAUNCHING"
          + name                 = "lifecycle-hook-update-test"
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_iam_role" "role" {
  assume_role_policy = jsonencode({
    Version   = "2012-10-17"
    Statement = [
      {
        Action    = "sts:AssumeRole"
        Effect    = "Allow"
        Principal = {
          Service = "ec2.amazonaws.com"
        }
      },
    ]
  })
  name = "launch-template-ec2-role"
  path = "/ec2/instance/"
}
resource "aws_iam_instance_profile" "instance_profile" {
  name = "ec2-instance-profile"
  path = "/ec2/instance/"
  role = aws_iam_role.role.name
}

resource "aws_launch_template" "lt" {
  description   = "Launch template for ec2"
  image_id      = "ami-06ca3ca175f37dd66"
  instance_type = "t3.nano"
  name          = "ec2-linux-1"
  iam_instance_profile {
    arn = aws_iam_instance_profile.instance_profile.arn
  }
}

resource "aws_autoscaling_group" "asg" {
  availability_zones = ["us-east-1a"]
  launch_template {
    name    = aws_launch_template.lt.name
    version = "$Latest"
  }
  max_size         = 1
  min_size         = 1
  desired_capacity = 1
  initial_lifecycle_hook {
    lifecycle_transition = "autoscaling:EC2_INSTANCE_LAUNCHING"
    default_result       = "CONTINUE"
    name                 = "lifecycle-hook-update-test"
    heartbeat_timeout    = 30
  }
}

Steps to Reproduce

  1. terraform apply
  2. Change heartbeat_timeout value to 40
  3. terraform apply
  4. Verify the updated value in AWS using web console or CLI

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

#4714

Would you like to implement a fix?

Yes

@dhrkumar dhrkumar added the bug Addresses a defect in current functionality. label Oct 31, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/autoscaling Issues and PRs that pertain to the autoscaling service. service/ec2 Issues and PRs that pertain to the ec2 service. service/iam Issues and PRs that pertain to the iam service. labels Oct 31, 2023
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 31, 2023
@ewbankkit ewbankkit removed service/iam Issues and PRs that pertain to the iam service. service/ec2 Issues and PRs that pertain to the ec2 service. needs-triage Waiting for first response or review from a maintainer. labels Nov 6, 2023
@github-actions github-actions bot added this to the v5.25.0 milestone Nov 6, 2023
Copy link

This functionality has been released in v5.25.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service.
Projects
None yet
2 participants