Merge pull request #3704 from dayer4b/add-placement-group
added placement group as an option for autoscaling groups
This commit is contained in:
commit
709d1f3599
|
@ -96,6 +96,11 @@ func resourceAwsAutoscalingGroup() *schema.Resource {
|
||||||
Set: schema.HashString,
|
Set: schema.HashString,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"placement_group": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
|
||||||
"load_balancers": &schema.Schema{
|
"load_balancers": &schema.Schema{
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
@ -185,6 +190,10 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{})
|
||||||
autoScalingGroupOpts.HealthCheckGracePeriod = aws.Int64(int64(v.(int)))
|
autoScalingGroupOpts.HealthCheckGracePeriod = aws.Int64(int64(v.(int)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v, ok := d.GetOk("placement_group"); ok {
|
||||||
|
autoScalingGroupOpts.PlacementGroup = aws.String(v.(string))
|
||||||
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("load_balancers"); ok && v.(*schema.Set).Len() > 0 {
|
if v, ok := d.GetOk("load_balancers"); ok && v.(*schema.Set).Len() > 0 {
|
||||||
autoScalingGroupOpts.LoadBalancerNames = expandStringList(
|
autoScalingGroupOpts.LoadBalancerNames = expandStringList(
|
||||||
v.(*schema.Set).List())
|
v.(*schema.Set).List())
|
||||||
|
@ -232,6 +241,7 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e
|
||||||
d.Set("load_balancers", g.LoadBalancerNames)
|
d.Set("load_balancers", g.LoadBalancerNames)
|
||||||
d.Set("min_size", g.MinSize)
|
d.Set("min_size", g.MinSize)
|
||||||
d.Set("max_size", g.MaxSize)
|
d.Set("max_size", g.MaxSize)
|
||||||
|
d.Set("placement_group", g.PlacementGroup)
|
||||||
d.Set("name", g.AutoScalingGroupName)
|
d.Set("name", g.AutoScalingGroupName)
|
||||||
d.Set("tag", g.Tags)
|
d.Set("tag", g.Tags)
|
||||||
d.Set("vpc_zone_identifier", strings.Split(*g.VPCZoneIdentifier, ","))
|
d.Set("vpc_zone_identifier", strings.Split(*g.VPCZoneIdentifier, ","))
|
||||||
|
@ -286,6 +296,10 @@ func resourceAwsAutoscalingGroupUpdate(d *schema.ResourceData, meta interface{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.HasChange("placement_group") {
|
||||||
|
opts.PlacementGroup = aws.String(d.Get("placement_group").(string))
|
||||||
|
}
|
||||||
|
|
||||||
if d.HasChange("termination_policies") {
|
if d.HasChange("termination_policies") {
|
||||||
// If the termination policy is set to null, we need to explicitly set
|
// If the termination policy is set to null, we need to explicitly set
|
||||||
// it back to "Default", or the API won't reset it for us.
|
// it back to "Default", or the API won't reset it for us.
|
||||||
|
|
|
@ -49,6 +49,8 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) {
|
||||||
"aws_autoscaling_group.bar", "termination_policies.0", "OldestInstance"),
|
"aws_autoscaling_group.bar", "termination_policies.0", "OldestInstance"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_autoscaling_group.bar", "termination_policies.1", "ClosestToNextInstanceHour"),
|
"aws_autoscaling_group.bar", "termination_policies.1", "ClosestToNextInstanceHour"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_autoscaling_group.bar", "placement_group", "test"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -401,6 +403,11 @@ resource "aws_launch_configuration" "foobar" {
|
||||||
instance_type = "t1.micro"
|
instance_type = "t1.micro"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_placement_group" "test" {
|
||||||
|
name = "test"
|
||||||
|
strategy = "cluster"
|
||||||
|
}
|
||||||
|
|
||||||
resource "aws_autoscaling_group" "bar" {
|
resource "aws_autoscaling_group" "bar" {
|
||||||
availability_zones = ["us-west-2a"]
|
availability_zones = ["us-west-2a"]
|
||||||
name = "foobar3-terraform-test"
|
name = "foobar3-terraform-test"
|
||||||
|
@ -411,6 +418,7 @@ resource "aws_autoscaling_group" "bar" {
|
||||||
desired_capacity = 4
|
desired_capacity = 4
|
||||||
force_delete = true
|
force_delete = true
|
||||||
termination_policies = ["OldestInstance","ClosestToNextInstanceHour"]
|
termination_policies = ["OldestInstance","ClosestToNextInstanceHour"]
|
||||||
|
placement_group = "${aws_placement_group.test.name}"
|
||||||
|
|
||||||
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,11 @@ Provides an AutoScaling Group resource.
|
||||||
## Example Usage
|
## Example Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
|
resource "aws_placement_group" "test" {
|
||||||
|
name = "test"
|
||||||
|
strategy = "cluster"
|
||||||
|
}
|
||||||
|
|
||||||
resource "aws_autoscaling_group" "bar" {
|
resource "aws_autoscaling_group" "bar" {
|
||||||
availability_zones = ["us-east-1a"]
|
availability_zones = ["us-east-1a"]
|
||||||
name = "foobar3-terraform-test"
|
name = "foobar3-terraform-test"
|
||||||
|
@ -22,6 +27,7 @@ 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
|
||||||
|
placement_group = "${aws_placement_group.test.id}"
|
||||||
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
||||||
|
|
||||||
tag {
|
tag {
|
||||||
|
@ -48,7 +54,7 @@ The following arguments are supported:
|
||||||
* `availability_zones` - (Optional) A list of AZs to launch resources in.
|
* `availability_zones` - (Optional) A list of AZs to launch resources in.
|
||||||
Required only if you do not specify any `vpc_zone_identifier`
|
Required only if you do not specify any `vpc_zone_identifier`
|
||||||
* `launch_configuration` - (Required) The name of the launch configuration to use.
|
* `launch_configuration` - (Required) The name of the launch configuration to use.
|
||||||
* `health_check_grace_period` - (Optional) Time after instance comes into service before checking health.
|
* `health_check_grace_period` - (Optional) Time after instance comes into service before checking health.
|
||||||
* `health_check_type` - (Optional) "EC2" or "ELB". Controls how health checking is done.
|
* `health_check_type` - (Optional) "EC2" or "ELB". Controls how health checking is done.
|
||||||
* `desired_capacity` - (Optional) The number of Amazon EC2 instances that
|
* `desired_capacity` - (Optional) The number of Amazon EC2 instances that
|
||||||
should be running in the group. (See also [Waiting for
|
should be running in the group. (See also [Waiting for
|
||||||
|
@ -66,6 +72,7 @@ The following arguments are supported:
|
||||||
* `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.
|
* `termination_policies` (Optional) A list of policies to decide how the instances in the auto scale group should be terminated.
|
||||||
* `tag` (Optional) A list of tag blocks. Tags documented below.
|
* `tag` (Optional) A list of tag blocks. Tags documented below.
|
||||||
|
* `placement_group` (Optional) The name of the placement group into which you'll launch your instances, if any.
|
||||||
* `wait_for_capacity_timeout` (Default: "10m") A maximum
|
* `wait_for_capacity_timeout` (Default: "10m") A maximum
|
||||||
[duration](https://golang.org/pkg/time/#ParseDuration) that Terraform should
|
[duration](https://golang.org/pkg/time/#ParseDuration) that Terraform should
|
||||||
wait for ASG instances to be healthy before timing out. (See also [Waiting
|
wait for ASG instances to be healthy before timing out. (See also [Waiting
|
||||||
|
|
Loading…
Reference in New Issue