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

aws_autoscaling_group collapses all tags with values unspecified until apply into a single value, resulting in an inconsistent plan on apply #17416

Closed
sriddell opened this issue Feb 2, 2021 · 2 comments
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service.

Comments

@sriddell
Copy link

sriddell commented Feb 2, 2021

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

Terraform v0.14.5

  • provider registry.terraform.io/hashicorp/aws v3.26.0
  • provider registry.terraform.io/hashicorp/random v3.0.1

Affected Resource(s)

  • aws_autoscaling_group

Terraform Configuration Files

Complete test cases showing working and error scenarios with detailed analysis/guesses in README.md at https://github.com/sriddell/aws_autoscaling_group_error_example

resource "random_string" "random" {
  length = 16
  special = true
  override_special = "/@£$"
}



data "aws_ami" "ubuntu" {
  most_recent = true

  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
  }

  filter {
    name   = "virtualization-type"
    values = ["hvm"]
  }

  owners = ["099720109477"] # Canonical
}

resource "aws_launch_configuration" "as_conf" {
  name          = "web_config"
  image_id      = data.aws_ami.ubuntu.id
  instance_type = "t2.micro"
}


resource "aws_autoscaling_group" "bar" {
  name                      = "shane1"
  max_size                  = 1
  min_size                  = 0
  health_check_grace_period = 300
  force_delete              = true
  vpc_zone_identifier       = ["subnet-0b64c3204be4d14c1"]
  launch_configuration = aws_launch_configuration.as_conf.name
  tags = [
      {
        "key"                 = "Name"
        "value"               = random_string.random.result
        "propagate_at_launch" = "true"
      },
      {
        "key"                 = "kubernetes.io/cluster/fixed"
        "value"               = random_string.random.result
        "propagate_at_launch" = "true"
      }
  ]

}

Debug Output

plan debug: https://gist.github.com/sriddell/4316a722c9b3186d16b998677ba24bdc
apply debug https://gist.github.com/sriddell/214c223b53484adc7374213830f90699
--->

Panic Output

Expected Behavior

Plan should have been applied without error.

Actual Behavior

Apply failed with "Provider produced inconsistent final plan".

The README.md in https://github.com/sriddell/aws_autoscaling_group_error_example has full details, but the basic problem appears to be that the aws_autoscaling_group resource, when presented with 2 or more tags in the "tags" attribute with keys or values that are unspecified until apply time, collapses them all down into a single unspecified value in the "tags" list. This means that when the plan is applied, the tags list expands to be larger than it as in the plan, which violates the checks in the assertValueCompatible function in compatible.go from terraform-core, which allows a list to shrink in size, but not expand during the apply.

Steps to Reproduce

  1. terraform plan -out plan
  2. terraform apply plan
@ghost ghost added service/autoscaling Issues and PRs that pertain to the autoscaling service. service/ec2 Issues and PRs that pertain to the ec2 service. labels Feb 2, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Feb 2, 2021
@sriddell sriddell changed the title aws_autoscaling_group collapses all tags with values unspecified until runtime into a single value, resulting in an inconsistent plan on apply aws_autoscaling_group collapses all tags with values unspecified until apply into a single value, resulting in an inconsistent plan on apply Feb 2, 2021
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. service/ec2 Issues and PRs that pertain to the ec2 service. labels Feb 3, 2021
@ewbankkit
Copy link
Contributor

@sriddell Thanks for raising this issue.
It has already been noticed in #14085. I'm going to close this one as a duplicate so that we can concentrate discussion in the linked issue.
Please add any additional comments there.

@ghost
Copy link

ghost commented Mar 6, 2021

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 6, 2021
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
Development

No branches or pull requests

2 participants