Termination Policy Support

This commit is contained in:
Madhu 2014-10-23 14:58:54 -07:00
parent 8788d3c25e
commit 7d4064ca03
3 changed files with 22 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import (
)
func resourceAwsAutoscalingGroup() *schema.Resource {
fmt.Println("HELLO WORLD")
return &schema.Resource{
Create: resourceAwsAutoscalingGroupCreate,
Read: resourceAwsAutoscalingGroupRead,
@ -105,6 +106,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 +160,11 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{})
autoScalingGroupOpts.VPCZoneIdentifier = expandStringList(
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)

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,7 +204,8 @@ 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