providers/aws: autoscaling updates, fix create for new goamz api
This commit is contained in:
parent
0d4fdfc6fd
commit
a55ee34aba
|
@ -28,22 +28,27 @@ func resource_aws_autoscaling_group_create(
|
||||||
|
|
||||||
if rs.Attributes["min_size"] != "" {
|
if rs.Attributes["min_size"] != "" {
|
||||||
autoScalingGroupOpts.MinSize, err = strconv.Atoi(rs.Attributes["min_size"])
|
autoScalingGroupOpts.MinSize, err = strconv.Atoi(rs.Attributes["min_size"])
|
||||||
|
autoScalingGroupOpts.SetMinSize = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.Attributes["max_size"] != "" {
|
if rs.Attributes["max_size"] != "" {
|
||||||
autoScalingGroupOpts.MaxSize, err = strconv.Atoi(rs.Attributes["max_size"])
|
autoScalingGroupOpts.MaxSize, err = strconv.Atoi(rs.Attributes["max_size"])
|
||||||
|
autoScalingGroupOpts.SetMaxSize = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.Attributes["default_cooldown"] != "" {
|
if rs.Attributes["default_cooldown"] != "" {
|
||||||
autoScalingGroupOpts.DefaultCooldown, err = strconv.Atoi(rs.Attributes["default_cooldown"])
|
autoScalingGroupOpts.DefaultCooldown, err = strconv.Atoi(rs.Attributes["default_cooldown"])
|
||||||
|
autoScalingGroupOpts.SetDefaultCooldown = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.Attributes["desired_capicity"] != "" {
|
if rs.Attributes["desired_capicity"] != "" {
|
||||||
autoScalingGroupOpts.DesiredCapacity, err = strconv.Atoi(rs.Attributes["desired_capicity"])
|
autoScalingGroupOpts.DesiredCapacity, err = strconv.Atoi(rs.Attributes["desired_capicity"])
|
||||||
|
autoScalingGroupOpts.SetDesiredCapacity = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.Attributes["health_check_grace_period"] != "" {
|
if rs.Attributes["health_check_grace_period"] != "" {
|
||||||
autoScalingGroupOpts.HealthCheckGracePeriod, err = strconv.Atoi(rs.Attributes["health_check_grace_period"])
|
autoScalingGroupOpts.HealthCheckGracePeriod, err = strconv.Atoi(rs.Attributes["health_check_grace_period"])
|
||||||
|
autoScalingGroupOpts.SetHealthCheckGracePeriod = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -91,13 +96,45 @@ func resource_aws_autoscaling_group_update(
|
||||||
s *terraform.ResourceState,
|
s *terraform.ResourceState,
|
||||||
d *terraform.ResourceDiff,
|
d *terraform.ResourceDiff,
|
||||||
meta interface{}) (*terraform.ResourceState, error) {
|
meta interface{}) (*terraform.ResourceState, error) {
|
||||||
|
p := meta.(*ResourceProvider)
|
||||||
|
autoscalingconn := p.autoscalingconn
|
||||||
rs := s.MergeDiff(d)
|
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(
|
func resource_aws_autoscaling_group_destroy(
|
||||||
|
@ -154,21 +191,29 @@ func resource_aws_autoscaling_group_diff(
|
||||||
|
|
||||||
b := &diff.ResourceBuilder{
|
b := &diff.ResourceBuilder{
|
||||||
Attrs: map[string]diff.AttrType{
|
Attrs: map[string]diff.AttrType{
|
||||||
"min_size": diff.AttrTypeCreate,
|
"availability_zone": diff.AttrTypeCreate,
|
||||||
"max_size": diff.AttrTypeCreate,
|
|
||||||
"default_cooldown": diff.AttrTypeCreate,
|
"default_cooldown": diff.AttrTypeCreate,
|
||||||
"name": diff.AttrTypeCreate,
|
|
||||||
"desired_capicity": diff.AttrTypeCreate,
|
"desired_capicity": diff.AttrTypeCreate,
|
||||||
|
"force_delete": diff.AttrTypeCreate,
|
||||||
"health_check_grace_period": diff.AttrTypeCreate,
|
"health_check_grace_period": diff.AttrTypeCreate,
|
||||||
"health_check_type": diff.AttrTypeCreate,
|
"health_check_type": diff.AttrTypeCreate,
|
||||||
"launch_configuration": diff.AttrTypeCreate,
|
"launch_configuration": diff.AttrTypeCreate,
|
||||||
"vpc_zone_identifier": diff.AttrTypeCreate,
|
|
||||||
"load_balancers": diff.AttrTypeCreate,
|
"load_balancers": diff.AttrTypeCreate,
|
||||||
"availability_zone": diff.AttrTypeCreate,
|
"name": diff.AttrTypeCreate,
|
||||||
"force_delete": 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)
|
return b.Diff(s, c)
|
||||||
|
|
|
@ -130,7 +130,9 @@ func resource_aws_launch_configuration_diff(
|
||||||
"security_groups": diff.AttrTypeCreate,
|
"security_groups": diff.AttrTypeCreate,
|
||||||
},
|
},
|
||||||
|
|
||||||
ComputedAttrs: []string{},
|
ComputedAttrs: []string{
|
||||||
|
"key_name",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return b.Diff(s, c)
|
return b.Diff(s, c)
|
||||||
|
|
|
@ -18,6 +18,7 @@ func init() {
|
||||||
Destroy: resource_aws_autoscaling_group_destroy,
|
Destroy: resource_aws_autoscaling_group_destroy,
|
||||||
Diff: resource_aws_autoscaling_group_diff,
|
Diff: resource_aws_autoscaling_group_diff,
|
||||||
Refresh: resource_aws_autoscaling_group_refresh,
|
Refresh: resource_aws_autoscaling_group_refresh,
|
||||||
|
Update: resource_aws_autoscaling_group_update,
|
||||||
},
|
},
|
||||||
|
|
||||||
"aws_elb": resource.Resource{
|
"aws_elb": resource.Resource{
|
||||||
|
|
Loading…
Reference in New Issue