Merge pull request #506 from muralimadhu/master

Support termination policies in aws auto scaling group
This commit is contained in:
Armon Dadgar 2014-12-07 23:35:33 -08:00
commit fae29f4685
3 changed files with 21 additions and 1 deletions

View File

@ -105,6 +105,17 @@ func resourceAwsAutoscalingGroup() *schema.Resource {
return hashcode.String(v.(string))
},
},
"termination_policies": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Computed: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
},
},
}
}
@ -148,6 +159,11 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{})
v.(*schema.Set).List())
}
if v, ok := d.GetOk("termination_policies"); ok {
autoScalingGroupOpts.TerminationPolicies = expandStringList(
v.(*schema.Set).List())
}
log.Printf("[DEBUG] AutoScaling Group create configuration: %#v", autoScalingGroupOpts)
_, err := autoscalingconn.CreateAutoScalingGroup(&autoScalingGroupOpts)
if err != nil {

View File

@ -38,6 +38,8 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) {
"aws_autoscaling_group.bar", "desired_capacity", "4"),
resource.TestCheckResourceAttr(
"aws_autoscaling_group.bar", "force_delete", "true"),
resource.TestCheckResourceAttr(
"aws_autoscaling_group.bar", "termination_policies.0", "OldestInstance"),
),
},
@ -202,6 +204,7 @@ resource "aws_autoscaling_group" "bar" {
health_check_type = "ELB"
desired_capacity = 4
force_delete = true
termination_policies = ["OldestInstance"]
launch_configuration = "${aws_launch_configuration.foobar.name}"
}

View File

@ -43,6 +43,7 @@ The following arguments are supported:
* `load_balancers` (Optional) A list of load balancer names to add to the autoscaling
group names.
* `vpc_zone_identifier` (Optional) A list of subnet IDs to launch resources in.
* `termination_policies` (Optional) A list of policies to decide how the instances in the auto scale group should be terminated.
## Attributes Reference