providers/aws: launch config and autoscale group load is correct

[GH-423]
This commit is contained in:
Mitchell Hashimoto 2014-10-16 16:39:58 -07:00
parent de4c922c9c
commit 1a2afdaa37
4 changed files with 5 additions and 39 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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
}

View File

@ -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))