diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go index 6aa20b9b6..f000531b8 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group.go @@ -28,22 +28,27 @@ func resource_aws_autoscaling_group_create( if rs.Attributes["min_size"] != "" { autoScalingGroupOpts.MinSize, err = strconv.Atoi(rs.Attributes["min_size"]) + autoScalingGroupOpts.SetMinSize = true } if rs.Attributes["max_size"] != "" { autoScalingGroupOpts.MaxSize, err = strconv.Atoi(rs.Attributes["max_size"]) + autoScalingGroupOpts.SetMaxSize = true } if rs.Attributes["default_cooldown"] != "" { autoScalingGroupOpts.DefaultCooldown, err = strconv.Atoi(rs.Attributes["default_cooldown"]) + autoScalingGroupOpts.SetDefaultCooldown = true } if rs.Attributes["desired_capicity"] != "" { autoScalingGroupOpts.DesiredCapacity, err = strconv.Atoi(rs.Attributes["desired_capicity"]) + autoScalingGroupOpts.SetDesiredCapacity = true } if rs.Attributes["health_check_grace_period"] != "" { autoScalingGroupOpts.HealthCheckGracePeriod, err = strconv.Atoi(rs.Attributes["health_check_grace_period"]) + autoScalingGroupOpts.SetHealthCheckGracePeriod = true } if err != nil { @@ -91,13 +96,45 @@ func resource_aws_autoscaling_group_update( s *terraform.ResourceState, d *terraform.ResourceDiff, meta interface{}) (*terraform.ResourceState, error) { - + p := meta.(*ResourceProvider) + autoscalingconn := p.autoscalingconn rs := s.MergeDiff(d) - log.Printf("ResourceDiff: %s", d) - log.Printf("ResourceState: %s", s) - log.Printf("Merged: %s", rs) - return nil, fmt.Errorf("Did not update") + opts := autoscaling.UpdateAutoScalingGroup{ + Name: rs.ID, + } + + var err error + + if _, ok := d.Attributes["min_size"]; ok { + opts.MinSize, err = strconv.Atoi(rs.Attributes["min_size"]) + opts.SetMinSize = true + } + + if _, ok := d.Attributes["max_size"]; ok { + opts.MaxSize, err = strconv.Atoi(rs.Attributes["max_size"]) + opts.SetMaxSize = true + } + + if err != nil { + return s, fmt.Errorf("Error parsing configuration: %s", err) + } + + log.Printf("[DEBUG] AutoScaling Group update configuration: %#v", opts) + + _, err = autoscalingconn.UpdateAutoScalingGroup(&opts) + + if err != nil { + return rs, fmt.Errorf("Error updating AutoScaling group: %s", err) + } + + g, err := resource_aws_autoscaling_group_retrieve(rs.ID, autoscalingconn) + + if err != nil { + return rs, err + } + + return resource_aws_autoscaling_group_update_state(rs, g) } func resource_aws_autoscaling_group_destroy( @@ -154,21 +191,29 @@ func resource_aws_autoscaling_group_diff( b := &diff.ResourceBuilder{ Attrs: map[string]diff.AttrType{ - "min_size": diff.AttrTypeCreate, - "max_size": diff.AttrTypeCreate, + "availability_zone": diff.AttrTypeCreate, "default_cooldown": diff.AttrTypeCreate, - "name": diff.AttrTypeCreate, "desired_capicity": diff.AttrTypeCreate, + "force_delete": diff.AttrTypeCreate, "health_check_grace_period": diff.AttrTypeCreate, "health_check_type": diff.AttrTypeCreate, "launch_configuration": diff.AttrTypeCreate, - "vpc_zone_identifier": diff.AttrTypeCreate, "load_balancers": diff.AttrTypeCreate, - "availability_zone": diff.AttrTypeCreate, - "force_delete": diff.AttrTypeCreate, + "name": diff.AttrTypeCreate, + "vpc_zone_identifier": diff.AttrTypeCreate, + + "max_size": diff.AttrTypeUpdate, + "min_size": diff.AttrTypeUpdate, }, - ComputedAttrs: []string{}, + ComputedAttrs: []string{ + "health_check_grace_period", + "health_check_type", + "default_cooldown", + "vpc_zone_identifier", + "desired_capicity", + "force_delete", + }, } return b.Diff(s, c) diff --git a/builtin/providers/aws/resource_aws_launch_configuration.go b/builtin/providers/aws/resource_aws_launch_configuration.go index faf80b55c..bc6997ed3 100644 --- a/builtin/providers/aws/resource_aws_launch_configuration.go +++ b/builtin/providers/aws/resource_aws_launch_configuration.go @@ -130,7 +130,9 @@ func resource_aws_launch_configuration_diff( "security_groups": diff.AttrTypeCreate, }, - ComputedAttrs: []string{}, + ComputedAttrs: []string{ + "key_name", + }, } return b.Diff(s, c) diff --git a/builtin/providers/aws/resources.go b/builtin/providers/aws/resources.go index b3f4181a9..83a6a5b64 100644 --- a/builtin/providers/aws/resources.go +++ b/builtin/providers/aws/resources.go @@ -18,6 +18,7 @@ func init() { Destroy: resource_aws_autoscaling_group_destroy, Diff: resource_aws_autoscaling_group_diff, Refresh: resource_aws_autoscaling_group_refresh, + Update: resource_aws_autoscaling_group_update, }, "aws_elb": resource.Resource{