terraform-provider-awscc icon indicating copy to clipboard operation
terraform-provider-awscc copied to clipboard

awscc_autoscaling_auto_scaling_group - vpc_zone_identifer values order can triggers drift

Open wellsiau-aws opened this issue 8 months ago • 0 comments

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
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the CloudFormation Open Coverage Roadmap.

Terraform CLI and Terraform AWS Cloud Control Provider Version

Affected Resource(s)

  • awscc_autoscaling_auto_scaling_group

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "awscc_autoscaling_auto_scaling_group" "example" {
  max_size = "1"
  min_size = "0"

  launch_template = {
    version            = awscc_ec2_launch_template.example.latest_version_number
    launch_template_id = awscc_ec2_launch_template.example.launch_template_id
  }

  desired_capacity    = "1"
  
  vpc_zone_identifier = [
    "subnet-0bdc9d9f3bcc6c3b6",
    "subnet-00079939c5eccd47c",
    "subnet-055dad5e3aaedbb14",
  ]

  depends_on = [
    awscc_ec2_launch_template.example
  ]
}

resource "awscc_ec2_launch_template" "example" {
  launch_template_data = {
    image_id      = data.aws_ami.amazon_linux.id
    instance_type = "t2.micro"
  }
  launch_template_name = "${data.aws_caller_identity.current.account_id}-launch-template"
}

data "aws_caller_identity" "current" {}

data "aws_ami" "amazon_linux" {
  most_recent = true
  owners      = ["amazon"]
  filter {
    name   = "name"
    values = ["amzn2-ami-hvm-*-gp2"]
  }

  filter {
    name   = "root-device-type"
    values = ["ebs"]
  }

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

  filter {
    name   = "architecture"
    values = ["x86_64"]
  }
}


Debug Output

2024-06-16T12:59:51.311-0700 [WARN]  Provider "registry.terraform.io/hashicorp/awscc" produced an unexpected new value for awscc_autoscaling_auto_scaling_group.example during refresh.
      - .vpc_zone_identifier[0]: was cty.StringVal("subnet-0bdc9d9f3bcc6c3b6"), but now cty.StringVal("subnet-055dad5e3aaedbb14")
      - .vpc_zone_identifier[1]: was cty.StringVal("subnet-00079939c5eccd47c"), but now cty.StringVal("subnet-0bdc9d9f3bcc6c3b6")
      - .vpc_zone_identifier[2]: was cty.StringVal("subnet-055dad5e3aaedbb14"), but now cty.StringVal("subnet-00079939c5eccd47c")
2024-06-16T12:59:51.312-0700 [DEBUG] skipping FixUpBlockAttrs
2024-06-16T12:59:51.316-0700 [DEBUG] provider.terraform-provider-awscc_v1.2.0_x5: Detected value change between proposed new state and prior state: tf_req_id=b14534ba-6528-a54f-252c-59a73b95c932 @caller=github.com/hashicorp/[email protected]/internal/fwserver/server_planresourcechange.go:208 @module=sdk.framework tf_attribute_path=vpc_zone_identifier tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_resource_type=awscc_autoscaling_auto_scaling_group tf_rpc=PlanResourceChange timestamp=2024-06-16T12:59:51.316-0700

Expected Behavior

Terraform plan should not trigger any drift

Actual Behavior

Terraform plan trigger drift but the plan output shows no changes:

Terraform will perform the following actions:

  # awscc_autoscaling_auto_scaling_group.example will be updated in-place
  ~ resource "awscc_autoscaling_auto_scaling_group" "example" {
      + capacity_rebalance                    = (known after apply)
      + context                               = (known after apply)
      + default_instance_warmup               = (known after apply)
      + desired_capacity_type                 = (known after apply)
        id                                    = "GZ8zfjDBZV9vOPcu2UWYMxiBQ-kWYOE10DAPGJ"
      + instance_id                           = (known after apply)
      + instance_maintenance_policy           = (known after apply)
      + launch_configuration_name             = (known after apply)
      + lifecycle_hook_specification_list     = (known after apply)
      + load_balancer_names                   = (known after apply)
      + max_instance_lifetime                 = (known after apply)
      + metrics_collection                    = (known after apply)
      + mixed_instances_policy                = (known after apply)
      + notification_configuration            = (known after apply)
      + notification_configurations           = (known after apply)
      + placement_group                       = (known after apply)
      + tags                                  = (known after apply)
      + target_group_ar_ns                    = (known after apply)
        # (13 unchanged attributes hidden)
    }

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

Steps to Reproduce

  1. terraform apply
  2. terraform plan
  3. Note that in your test, you might need to change the order of the subnets

Important Factoids

Plan modifiers for vpc_zone_identifier is using generic.multiset, this should in theory already ignores the ordering. Ref: https://github.com/hashicorp/terraform-provider-awscc/blob/2313ee23dca19793e7244a73ef8e7a84bce21b0f/internal/aws/autoscaling/auto_scaling_group_resource_gen.go#L1810-L1816)

Ref: https://github.com/hashicorp/terraform-provider-awscc/blob/2313ee23dca19793e7244a73ef8e7a84bce21b0f/internal/generic/multiset.go#L15-L20

References

wellsiau-aws avatar Jun 16 '24 20:06 wellsiau-aws