provider/aws: Fixing ASG handling of not found
This commit is contained in:
parent
124d9fc0bd
commit
0ff62016ee
|
@ -296,17 +296,16 @@ func getAwsAutoscalingGroup(
|
|||
return nil, fmt.Errorf("Error retrieving AutoScaling groups: %s", err)
|
||||
}
|
||||
|
||||
// Verify AWS returned our sg
|
||||
if len(describeGroups.AutoScalingGroups) != 1 ||
|
||||
describeGroups.AutoScalingGroups[0].Name != d.Id() {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"Unable to find AutoScaling group: %#v",
|
||||
describeGroups.AutoScalingGroups)
|
||||
// Search for the autoscaling group
|
||||
for idx, asc := range describeGroups.AutoScalingGroups {
|
||||
if asc.Name == d.Id() {
|
||||
return &describeGroups.AutoScalingGroups[idx], nil
|
||||
}
|
||||
}
|
||||
|
||||
return &describeGroups.AutoScalingGroups[0], nil
|
||||
// ASG not found
|
||||
d.SetId("")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func resourceAwsAutoscalingGroupDrain(d *schema.ResourceData, meta interface{}) error {
|
||||
|
|
Loading…
Reference in New Issue