terraform-provider-aws: Unexpected diffs on aws_autoscaling_group since v2.63.0

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 Version

Terraform v0.12.25
+ provider.aws v2.63.0

Affected Resource(s)

  • aws_autoscaling_group

Terraform Configuration Files

data "aws_ami" "ubuntu" {
  most_recent = true

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

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

  owners = ["099720109477"] # Canonical
}

data "aws_vpc" "default" {
  default = true
}

data "aws_subnet_ids" "subs" {
  vpc_id = data.aws_vpc.default.id
}

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                 = "foobar3-terraform-test"
  max_size             = 0
  min_size             = 0
  desired_capacity     = 0
  launch_configuration = aws_launch_configuration.as_conf.name
  vpc_zone_identifier  = data.aws_subnet_ids.subs.ids

  tags = [
    {
      key                 = "foo"
      value               = "bar"
      propagate_at_launch = true
    },
    {
      key                 = "foo2"
      value               = "bar2"
      propagate_at_launch = true
    },
    {
      key                 = "2foo"
      value               = "2bar"
      propagate_at_launch = true
    },
  ]
}

Debug Output

Panic Output

Expected Behavior

No diff every run when the configuration has not changed.

Actual Behavior

Every plan produces the same diff:

  # aws_autoscaling_group.bar will be updated in-place
  ~ resource "aws_autoscaling_group" "bar" {
        arn                       = "arn:aws:autoscaling:us-east-1:111111111111:autoScalingGroup:5603abf2-a424-407b-b417-95bc90eb8c9f:autoScalingGroupName/foobar3-terraform-test"
        availability_zones        = [
            "us-east-1a",
            "us-east-1b",
            "us-east-1c",
            "us-east-1d",
            "us-east-1e",
            "us-east-1f",
        ]
        default_cooldown          = 300
        desired_capacity          = 0
        enabled_metrics           = []
        force_delete              = false
        health_check_grace_period = 300
        health_check_type         = "EC2"
        id                        = "foobar3-terraform-test"
        launch_configuration      = "web_config"
        load_balancers            = []
        max_instance_lifetime     = 0
        max_size                  = 0
        metrics_granularity       = "1Minute"
        min_size                  = 0
        name                      = "foobar3-terraform-test"
        protect_from_scale_in     = false
        service_linked_role_arn   = "arn:aws:iam::111111111111:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"
        suspended_processes       = []
      ~ tags                      = [
          - {
              - "key"                 = "2foo"
              - "propagate_at_launch" = "true"
              - "value"               = "2bar"
            },
            {
                "key"                 = "foo"
                "propagate_at_launch" = "true"
                "value"               = "bar"
            },
            {
                "key"                 = "foo2"
                "propagate_at_launch" = "true"
                "value"               = "bar2"
            },
          + {
              + "key"                 = "2foo"
              + "propagate_at_launch" = "true"
              + "value"               = "2bar"
            },
        ]
        target_group_arns         = []
        termination_policies      = []
        vpc_zone_identifier       = [
            "subnet-a",
            "subnet-b",
            "subnet-c",
            "subnet-d",
            "subnet-e",
            "subnet-f",
        ]
        wait_for_capacity_timeout = "10m"
    }

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

Downgrading to 2.62.0 produces a diff on the first apply so this new order is being stored in the state file.

Steps to Reproduce

  1. terraform apply

Important Factoids

Regression introduced in 2.63.0.

Does not happen for every state if you happen to have the tags in the “correct” order.

References

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 37
  • Comments: 18 (3 by maintainers)

Commits related to this issue

Most upvoted comments

The fix for the tags ordering issue has been merged and will release with version 2.64.0 of the Terraform AWS Provider, likely tomorrow.

@bflad any input on this issue will be appreciated ^^

when I use tag blocks in the aws_autoscaling_group resource, I get no diffs If I use null data source, it gets me diff in every plan:

data "null_data_source" "tags" {
   count = "${length(keys(var.common_tags))}"
    
   inputs = {
    key                 = "${element(keys(var.common_tags), count.index)}"
    value               = "${element(values(var.common_tags), count.index)}"
    propagate_at_launch = true
    }
 }
resource "aws_autoscaling_group" "ecs_autoscaling_group" {
    tags = ["${data.null_data_source.tags.*.outputs}"]
}

The bug seems still present on v2.64.0