Skip to content

Unwarranted changes when updating tags on aws_autoscaling_group #15227

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

Closed
philbal611 opened this issue Sep 18, 2020 · 3 comments
Closed

Unwarranted changes when updating tags on aws_autoscaling_group #15227

philbal611 opened this issue Sep 18, 2020 · 3 comments
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. stale Old or inactive issues managed by automation, if no further action taken these will get closed. upstream Addresses functionality related to the cloud provider.

Comments

@philbal611
Copy link
Contributor

philbal611 commented Sep 18, 2020

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.12.13
provider.aws v3.7.0

Affected Resource(s)

  • aws_autoscaling_group

Terraform Configuration Files

resource "aws_launch_configuration" "example" {
  .
  .
  .
}

resource "aws_autoscaling_group" "example" {
  name                 = "example"
  launch_configuration = "${aws_launch_configuration.example.name}"
  min_size             = "1"
  max_size             = "1"

  tags = [
    {
      key                 = "Name"
      value               = "example"
      propagate_at_launch = true
    },
    {
      key                 = "Owner"
      value               = "bezos"
      propagate_at_launch = true
    },
  ]
}

Debug Output

Panic Output

Expected Behavior

After the aws_autoscaling_group has applied, when deleting a tag or updating an existing tag, only that change should plan.

Actual Behavior

The deleted/updated tag update is shown, as well as an empty map entry, shown as {} in the plan.

Steps to Reproduce

  1. Configure the aws_autoscaling_group
  2. Run terraform apply
  3. Once deployed, either update or delete one of the tags:
resource "aws_autoscaling_group" "example" {
  name                 = "example"
  launch_configuration = "${aws_launch_configuration.example.name}"
  min_size             = "1"
  max_size             = "1"

  tags = [
    {
      key                 = "Name"
      value               = "example"
      propagate_at_launch = true
    },
    {
      key                 = "Owner"
      value               = "gates" // <--- changed from "bezos"
      propagate_at_launch = true
    },
  ]
}
  1. Run terraform plan and review the output:
 # aws_autoscaling_group.example will be updated in-place
  ~ resource "aws_autoscaling_group" "example" {
        arn                       = "<arn>"
        availability_zones        = []
        default_cooldown          = 300
        desired_capacity          = 1
        enabled_metrics           = []
        force_delete              = false
        health_check_grace_period = 300
        health_check_type         = "EC2"
        id                        = "example"
        launch_configuration      = "launch_configuration_example"
        load_balancers            = []
        max_instance_lifetime     = 0
        max_size                  = 1
        metrics_granularity       = "1Minute"
        min_size                  = 1
        name                      = "example"
        protect_from_scale_in     = false
        service_linked_role_arn   = "<arn>"
        suspended_processes       = []
      ~ tags                      = [
          + {
              + "key"                 = "Owner"
              + "propagate_at_launch" = "true"
              + "value"               = "gates"
            },
          - {
              - "key"                 = "Owner"
              - "propagate_at_launch" = "true"
              - "value"               = "bezos"
            },
            {
                "key"                 = "Name"
                "propagate_at_launch" = "true"
                "value"               = "example"
            },
          + {}, // <--- this change is not configured in code
        ]
        target_group_arns         = []
        termination_policies      = []
        vpc_zone_identifier       = []
        wait_for_capacity_timeout = "10m"
    }

Important Factoids

This specific anomaly doesn't seem harmful...the empty map does persist in state once applied, but it doesn't change anything to the actual resource. The only time we caught it is when we ran it in TFE against our AWS Tags policy, which iterates through each tags map for the aws_autoscaling_group resource. When this extra empty map shows up, it breaks our policy. We've gotten around the policy issue in the meantime, but the provider issue still stands.

References

  • #0000
@ghost ghost added the service/autoscaling Issues and PRs that pertain to the autoscaling service. label Sep 18, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 18, 2020
@anGie44 anGie44 added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 18, 2020
@anGie44
Copy link
Contributor

anGie44 commented Sep 18, 2020

Notes: I'm able to reproduce this in versions as early as v2.64.0 of the provider when tags was updated from a List to Set

Update: feels like a terraform-plugin-sdk related bug; if I take the current version of the provider but change the tags type to a List, I see the diff without an empty map :

    ~ tags                      = [
          - {
              - "key"                 = "Owner"
              - "propagate_at_launch" = "true"
              - "value"               = "bezos"
            },
            {
                "key"                 = "Name"
                "propagate_at_launch" = "true"
                "value"               = "example"
            },
          + {
              + "key"                 = "Owner"
              + "propagate_at_launch" = "true"
              + "value"               = "gates"
            },
        ]

@github-actions
Copy link

github-actions bot commented Sep 9, 2022

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Sep 9, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2022
@github-actions
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 Nov 10, 2022
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. stale Old or inactive issues managed by automation, if no further action taken these will get closed. upstream Addresses functionality related to the cloud provider.
Projects
None yet
Development

No branches or pull requests

2 participants