Skip to content

Commit

Permalink
Merge pull request #7821 from terraform-providers/b-aws_autoscaling_g…
Browse files Browse the repository at this point in the history
…roup-mip-id-zero-values

resource/aws_autoscaling_group: Configure mixed_instances_policy instance_distribution on_demand_base_capacity and spot_max_price argument zero values
  • Loading branch information
bflad authored Mar 6, 2019
2 parents 1d6e634 + f90c9a3 commit 32e85c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aws/resource_aws_autoscaling_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ func expandAutoScalingInstancesDistribution(l []interface{}) *autoscaling.Instan
instancesDistribution.OnDemandAllocationStrategy = aws.String(v.(string))
}

if v, ok := m["on_demand_base_capacity"]; ok && v.(int) != 0 {
if v, ok := m["on_demand_base_capacity"]; ok {
instancesDistribution.OnDemandBaseCapacity = aws.Int64(int64(v.(int)))
}

Expand All @@ -1275,7 +1275,7 @@ func expandAutoScalingInstancesDistribution(l []interface{}) *autoscaling.Instan
instancesDistribution.SpotInstancePools = aws.Int64(int64(v.(int)))
}

if v, ok := m["spot_max_price"]; ok && v.(string) != "" {
if v, ok := m["spot_max_price"]; ok {
instancesDistribution.SpotMaxPrice = aws.String(v.(string))
}

Expand Down
18 changes: 18 additions & 0 deletions aws/resource_aws_autoscaling_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,15 @@ func TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_OnDem
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.instances_distribution.0.on_demand_base_capacity", "2"),
),
},
{
Config: testAccAWSAutoScalingGroupConfig_MixedInstancesPolicy_InstancesDistribution_OnDemandBaseCapacity(rName, 0),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAutoScalingGroupExists(resourceName, &group),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.#", "1"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.instances_distribution.#", "1"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.instances_distribution.0.on_demand_base_capacity", "0"),
),
},
},
})
}
Expand Down Expand Up @@ -1287,6 +1296,15 @@ func TestAccAWSAutoScalingGroup_MixedInstancesPolicy_InstancesDistribution_SpotM
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.instances_distribution.0.spot_max_price", "0.51"),
),
},
{
Config: testAccAWSAutoScalingGroupConfig_MixedInstancesPolicy_InstancesDistribution_SpotMaxPrice(rName, ""),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAutoScalingGroupExists(resourceName, &group),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.#", "1"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.instances_distribution.#", "1"),
resource.TestCheckResourceAttr(resourceName, "mixed_instances_policy.0.instances_distribution.0.spot_max_price", ""),
),
},
},
})
}
Expand Down

0 comments on commit 32e85c1

Please sign in to comment.