Merge pull request #506 from muralimadhu/master
Support termination policies in aws auto scaling group
This commit is contained in:
commit
fae29f4685
|
@ -105,6 +105,17 @@ func resourceAwsAutoscalingGroup() *schema.Resource {
|
||||||
return hashcode.String(v.(string))
|
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))
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,6 +158,11 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{})
|
||||||
autoScalingGroupOpts.VPCZoneIdentifier = expandStringList(
|
autoScalingGroupOpts.VPCZoneIdentifier = expandStringList(
|
||||||
v.(*schema.Set).List())
|
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)
|
log.Printf("[DEBUG] AutoScaling Group create configuration: %#v", autoScalingGroupOpts)
|
||||||
_, err := autoscalingconn.CreateAutoScalingGroup(&autoScalingGroupOpts)
|
_, err := autoscalingconn.CreateAutoScalingGroup(&autoScalingGroupOpts)
|
||||||
|
|
|
@ -38,6 +38,8 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) {
|
||||||
"aws_autoscaling_group.bar", "desired_capacity", "4"),
|
"aws_autoscaling_group.bar", "desired_capacity", "4"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_autoscaling_group.bar", "force_delete", "true"),
|
"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"
|
health_check_type = "ELB"
|
||||||
desired_capacity = 4
|
desired_capacity = 4
|
||||||
force_delete = true
|
force_delete = true
|
||||||
|
termination_policies = ["OldestInstance"]
|
||||||
|
|
||||||
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
|
@ -43,6 +43,7 @@ The following arguments are supported:
|
||||||
* `load_balancers` (Optional) A list of load balancer names to add to the autoscaling
|
* `load_balancers` (Optional) A list of load balancer names to add to the autoscaling
|
||||||
group names.
|
group names.
|
||||||
* `vpc_zone_identifier` (Optional) A list of subnet IDs to launch resources in.
|
* `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
|
## Attributes Reference
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue