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

Launch Template version update issue in AutoScaling group is not updated on change #25757

Open
chaitanyakommoju opened this issue Jul 9, 2022 · 4 comments
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@chaitanyakommoju
Copy link

chaitanyakommoju commented Jul 9, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • 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
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

I don't think the terraform version matters, but anyways here are details, I'm using terrafrom version v1.2.4 and AWS provider 4.22.0

$ terraform --version
Terraform v1.2.4
on windows_amd64
+ provider registry.terraform.io/hashicorp/aws v4.22.0
+ provider registry.terraform.io/hashicorp/random v3.3.2

Affected Resource(s)

  • aws_autoscaling_group
  • aws_launch_template

Terraform Configuration Files

module "app_ec2_asg" {
  source  = "terraform-aws-modules/autoscaling/aws"
  version = "6.3.0"
  # Autoscaling group
  name                      = asg_ec2
  create_launch_template    = true
  min_size                  = 1
  max_size                  = 2
  desired_capacity          = 1
  wait_for_capacity_timeout = 0
  default_cooldown          = 600
  target_group_arns         = module.alb.target_group_arns
  health_check_type         = "EC2"
  vpc_zone_identifier       = module.app_vpc.public_subnets
  security_groups           = [module.app_sg.security_group_id]
  user_data                 = local.ec2_userdata_scripts
  # Launch template
  launch_template_name        = var.ec2_launch_template_name
  launch_template_description = "APP EC2 Launch template "
  update_default_version      = true
  image_id                    = data.aws_ami.amazon_linux_2.id
  instance_type               = var.app_instance_type
  ebs_optimized               = true
  enable_monitoring           = true
  key_name                    = module.ec2_key_pair.key_pair_key_name
  disable_api_termination     = true
  iam_instance_profile_name   = aws_iam_instance_profile.ec2_s3_access_profile.name
  scaling_policies = {
    my-policy = {
      policy_type = "TargetTrackingScaling"
      target_tracking_configuration = {
        predefined_metric_specification = {
          predefined_metric_type = "ASGAverageCPUUtilization"
        }
        target_value = 50.0
      }
    }
  }
  block_device_mappings = [
    {
      # Root volume
      device_name = "/dev/xvda"
      no_device   = 0
      ebs = {
        delete_on_termination = true
        encrypted             = true
        volume_size           = 20
        volume_type           = "gp2"
      }
    }
  ]

  metadata_options = {
    http_endpoint               = "enabled"
    http_tokens                 = "required"
    http_put_response_hop_limit = 5
  }

  tags = {
    vpc_name    = "${var.app_vpc_name}"
    app_name    = "${var.app_name}"
    Environment = "${var.app_environment}"
    Terraform   = "true"
  }

}

Debug Output

╷
│ Error: Provider produced inconsistent final plan
│
│ When expanding the plan for module.app_ec2_asg.aws_autoscaling_group.this[0] to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new     
│ value for .launch_template[0].version: was cty.StringVal("7"), but now cty.StringVal("8").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Panic Output

Expected Behavior

After making any change in the autoscaling group and launching template configuration or in any other resources, it should apply the launch template version to the latest and also should apply the changes

Actual Behavior

After making any change in the autoscaling group and launching template configuration or in any other resources, it should apply the launch template version to the latest and also should apply the changes instead of this, it is throwing the error

╷
│ Error: Provider produced inconsistent final plan
│
│ When expanding the plan for module.app_ec2_asg.aws_autoscaling_group.this[0] to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new     
│ value for .launch_template[0].version: was cty.StringVal("7"), but now cty.StringVal("8").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Steps to Reproduce

Use the above terraform configuration provided and with terraform CLI version v1.2.4 and was module versions v4.22.0 and it can be reproduced

  1. terraform apply
  2. confirm the changes with yes

Important Factoids

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. service/ec2 Issues and PRs that pertain to the ec2 service. labels Jul 9, 2022
@chaitanyakommoju
Copy link
Author

ewbankkit can you please look into this issue

@chaitanyakommoju
Copy link
Author

some can take this and resolve or some one can help out to resolve this issue

@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jul 25, 2022
@BradyShober
Copy link

We are encountering this error as well on v4.23.0 of the provider. In our case, our launch templates we use for our auto scaling groups use custom AMIs. When we publish an updated AMI, we have a process that will automatically update each launch template to use the new AMI. However, the next time we try to apply the Terraform for one of our auto scaling groups after we have published a new AMI, that error is thrown. When it does occur we can just rerun the Terraform and on the second run it will succeed, so while we have that workaround it is not ideal, and will cause some frustration with our application development teams as we begin our rollout of auto scaling within our organization.

@jfirebaugh
Copy link

This continues to happen with 5.23.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

4 participants