From 1a2afdaa373cb3019d4f1f7c677919d1a3031250 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 16 Oct 2014 16:39:58 -0700 Subject: [PATCH] providers/aws: launch config and autoscale group load is correct [GH-423] --- CHANGELOG.md | 2 ++ .../aws/resource_aws_autoscaling_group.go | 7 ++--- .../aws/resource_aws_launch_configuration.go | 5 +--- builtin/providers/aws/structure.go | 30 ------------------- 4 files changed, 5 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb0dfc47e..de0329007 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ BUG FIXES: * core: Fix a hang that can occur with enough resources. [GH-410] * core: Config validation will not error if the field is being computed so the value is still unknown. + * providers/aws: Refresh of launch configs and autoscale groups load + the correct data and don't incorrectly recreate themselves. [GH-425] ## 0.3.0 (October 14, 2014) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go index a5f4a2de7..1aebfd9a0 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group.go @@ -251,20 +251,17 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e g := describeGroups.AutoScalingGroups[0] - d.Set("availability_zones", flattenAvailabilityZones(g.AvailabilityZones)) + d.Set("availability_zones", g.AvailabilityZones) d.Set("default_cooldown", g.DefaultCooldown) d.Set("desired_capacity", g.DesiredCapacity) d.Set("health_check_grace_period", g.HealthCheckGracePeriod) d.Set("health_check_type", g.HealthCheckType) d.Set("launch_configuration", g.LaunchConfigurationName) + d.Set("load_balancers", g.LoadBalancerNames) d.Set("min_size", g.MinSize) d.Set("max_size", g.MaxSize) d.Set("name", g.Name) d.Set("vpc_zone_identifier", g.VPCZoneIdentifier) - if len(g.LoadBalancerNames) > 0 && g.LoadBalancerNames[0].LoadBalancerName != "" { - d.Set("load_balancers", flattenLoadBalancers(g.LoadBalancerNames)) - } - return nil } diff --git a/builtin/providers/aws/resource_aws_launch_configuration.go b/builtin/providers/aws/resource_aws_launch_configuration.go index 6ae23cab6..584bad164 100644 --- a/builtin/providers/aws/resource_aws_launch_configuration.go +++ b/builtin/providers/aws/resource_aws_launch_configuration.go @@ -162,10 +162,7 @@ func resourceAwsLaunchConfigurationRead(d *schema.ResourceData, meta interface{} d.Set("image_id", lc.ImageId) d.Set("instance_type", lc.InstanceType) d.Set("name", lc.Name) - - if v := lc.SecurityGroups; len(v) > 0 && v[0].SecurityGroup != "" { - d.Set("security_groups", flattenAutoscalingSecurityGroups(v)) - } + d.Set("security_groups", lc.SecurityGroups) return nil } diff --git a/builtin/providers/aws/structure.go b/builtin/providers/aws/structure.go index 699e3ac14..ae8f707de 100644 --- a/builtin/providers/aws/structure.go +++ b/builtin/providers/aws/structure.go @@ -3,7 +3,6 @@ package aws import ( "strings" - "github.com/mitchellh/goamz/autoscaling" "github.com/mitchellh/goamz/ec2" "github.com/mitchellh/goamz/elb" ) @@ -138,35 +137,6 @@ func flattenSecurityGroups(list []ec2.UserSecurityGroup) []string { return result } -// Flattens an array of SecurityGroups into a []string -func flattenAutoscalingSecurityGroups(list []autoscaling.SecurityGroup) []string { - result := make([]string, 0, len(list)) - for _, g := range list { - result = append(result, g.SecurityGroup) - } - return result -} - -// Flattens an array of AvailabilityZones into a []string -func flattenAvailabilityZones(list []autoscaling.AvailabilityZone) []string { - result := make([]string, 0, len(list)) - for _, g := range list { - result = append(result, g.AvailabilityZone) - } - return result -} - -// Flattens an array of LoadBalancerName into a []string -func flattenLoadBalancers(list []autoscaling.LoadBalancerName) []string { - result := make([]string, 0, len(list)) - for _, g := range list { - if g.LoadBalancerName != "" { - result = append(result, g.LoadBalancerName) - } - } - return result -} - // Flattens an array of Instances into a []string func flattenInstances(list []elb.Instance) []string { result := make([]string, 0, len(list))