Skip to content

Commit

Permalink
Merge pull request #11357 from kkopachev/issue-11336
Browse files Browse the repository at this point in the history
aws_autoscaling_group waits for enough WeightedCapacity if instance weight specified
  • Loading branch information
gdavison authored Jan 13, 2020
2 parents c61cdea + 6ae1473 commit 0331631
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
14 changes: 7 additions & 7 deletions aws/resource_aws_autoscaling_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2036,9 +2036,9 @@ func TestAccAWSAutoScalingGroup_MixedInstancesPolicy_LaunchTemplate_Override_Wei
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.launch_template.#", "1"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.launch_template.0.override.#", "2"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.launch_template.0.override.0.instance_type", "t2.micro"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.launch_template.0.override.0.weighted_capacity", "1"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.launch_template.0.override.0.weighted_capacity", "2"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.launch_template.0.override.1.instance_type", "t3.small"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.launch_template.0.override.1.weighted_capacity", "2"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.launch_template.0.override.1.weighted_capacity", "4"),
),
},
{
Expand Down Expand Up @@ -3980,9 +3980,9 @@ func testAccAWSAutoScalingGroupConfig_MixedInstancesPolicy_LaunchTemplate_Overri
return testAccAWSAutoScalingGroupConfig_MixedInstancesPolicy_Base(rName) + fmt.Sprintf(`
resource "aws_autoscaling_group" "test" {
availability_zones = ["${data.aws_availability_zones.available.names[0]}"]
desired_capacity = 0
max_size = 0
min_size = 0
desired_capacity = 4
max_size = 6
min_size = 2
name = %q
mixed_instances_policy {
Expand All @@ -3993,11 +3993,11 @@ resource "aws_autoscaling_group" "test" {
override {
instance_type = "t2.micro"
weighted_capacity = "1"
weighted_capacity = "2"
}
override {
instance_type = "t3.small"
weighted_capacity = "2"
weighted_capacity = "4"
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion aws/resource_aws_autoscaling_group_waiting.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"fmt"
"log"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -121,7 +122,15 @@ func isELBCapacitySatisfied(d *schema.ResourceData, meta interface{}, g *autosca
continue
}

haveASG++
capacity := 1
if i.WeightedCapacity != nil {
capacity, err = strconv.Atoi(*i.WeightedCapacity)
if err != nil {
capacity = 1
}
}

haveASG += capacity

inAllLbs := true
for _, states := range elbis {
Expand Down

0 comments on commit 0331631

Please sign in to comment.