Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_autoscaling_group: Configure mixed_instances_policy instance_distribution on_demand_base_capacity and spot_max_price argument zero values #7821

Merged
merged 1 commit into from
Mar 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aws/resource_aws_autoscaling_group.go
Original file line number Diff line number Diff line change
@@ -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)))
}

@@ -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))
}

18 changes: 18 additions & 0 deletions aws/resource_aws_autoscaling_group_test.go
Original file line number Diff line number Diff line change
@@ -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"),
),
},
},
})
}
@@ -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", ""),
),
},
},
})
}