provider/aws: id-only refresh for autoscaling groups

This commit is contained in:
Mitchell Hashimoto 2016-04-21 21:36:14 -07:00
parent dcf0996015
commit f0511631bf
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
4 changed files with 21 additions and 4 deletions

View File

@ -95,6 +95,7 @@ BUG FIXES:
* provider/aws: `aws_customer_gateway` will properly populate `bgp_asn` on refresh. [no issue] * 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: 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_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/azurerm: Fix detection of `azurerm_storage_account` resources removed manually [GH-5878]
* provider/docker: Docker Image will be deleted on destroy [GH-5801] * provider/docker: Docker Image will be deleted on destroy [GH-5801]
* provider/openstack: Fix Disabling DHCP on Subnets [GH-6052] * provider/openstack: Fix Disabling DHCP on Subnets [GH-6052]

View File

@ -159,6 +159,20 @@ func autoscalingTagDescriptionsToMap(ts *[]*autoscaling.TagDescription) map[stri
return tags 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{} { func setToMapByKey(s *schema.Set, key string) map[string]interface{} {
result := make(map[string]interface{}) result := make(map[string]interface{})
for _, rawData := range s.List() { for _, rawData := range s.List() {

View File

@ -273,7 +273,7 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e
d.Set("max_size", g.MaxSize) d.Set("max_size", g.MaxSize)
d.Set("placement_group", g.PlacementGroup) d.Set("placement_group", g.PlacementGroup)
d.Set("name", g.AutoScalingGroupName) 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, ",")) d.Set("vpc_zone_identifier", strings.Split(*g.VPCZoneIdentifier, ","))
// If no termination polices are explicitly configured and the upstream state // If no termination polices are explicitly configured and the upstream state

View File

@ -22,9 +22,11 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) {
randName := fmt.Sprintf("terraform-test-%s", acctest.RandString(10)) randName := fmt.Sprintf("terraform-test-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, IDRefreshName: "aws_autoscaling_group.bar",
CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy, IDRefreshIgnore: []string{"force_delete", "metrics_granularity", "wait_for_capacity_timeout"},
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccAWSAutoScalingGroupConfig(randName), Config: testAccAWSAutoScalingGroupConfig(randName),