diff --git a/CHANGELOG.md b/CHANGELOG.md index 49c92a2c5..642ec8a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,6 +95,7 @@ BUG FIXES: * provider/aws: `aws_customer_gateway` will properly populate `bgp_asn` on refresh. [no issue] * provider/aws: provider/aws: Refresh state on `aws_directory_service_directory` not found [GH-6294] * provider/aws: `aws_elb` `cross_zone_load_balancing` is not refreshed in the state file [GH-6295] + * provider/aws: `aws_autoscaling_group` will properly populate `tag` on refresh. [no issue] * provider/azurerm: Fix detection of `azurerm_storage_account` resources removed manually [GH-5878] * provider/docker: Docker Image will be deleted on destroy [GH-5801] * provider/openstack: Fix Disabling DHCP on Subnets [GH-6052] diff --git a/builtin/providers/aws/autoscaling_tags.go b/builtin/providers/aws/autoscaling_tags.go index ecc4164a0..e6eef8ec6 100644 --- a/builtin/providers/aws/autoscaling_tags.go +++ b/builtin/providers/aws/autoscaling_tags.go @@ -159,6 +159,20 @@ func autoscalingTagDescriptionsToMap(ts *[]*autoscaling.TagDescription) map[stri return tags } +// autoscalingTagDescriptionsToSlice turns the list of tags into a slice. +func autoscalingTagDescriptionsToSlice(ts []*autoscaling.TagDescription) []map[string]interface{} { + tags := make([]map[string]interface{}, 0, len(ts)) + for _, t := range ts { + tags = append(tags, map[string]interface{}{ + "key": *t.Key, + "value": *t.Value, + "propagate_at_launch": *t.PropagateAtLaunch, + }) + } + + return tags +} + func setToMapByKey(s *schema.Set, key string) map[string]interface{} { result := make(map[string]interface{}) for _, rawData := range s.List() { diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go index 6c30fd495..795d59ea3 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group.go @@ -273,7 +273,7 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e d.Set("max_size", g.MaxSize) d.Set("placement_group", g.PlacementGroup) d.Set("name", g.AutoScalingGroupName) - d.Set("tag", g.Tags) + d.Set("tag", autoscalingTagDescriptionsToSlice(g.Tags)) d.Set("vpc_zone_identifier", strings.Split(*g.VPCZoneIdentifier, ",")) // If no termination polices are explicitly configured and the upstream state diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go index c41b3dc6e..5c63970c4 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go @@ -22,9 +22,11 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) { randName := fmt.Sprintf("terraform-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "aws_autoscaling_group.bar", + IDRefreshIgnore: []string{"force_delete", "metrics_granularity", "wait_for_capacity_timeout"}, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ Config: testAccAWSAutoScalingGroupConfig(randName),