@@ -220,7 +220,7 @@ func resourceIBMISInstanceGroupCreate(d *schema.ResourceData, meta interface{})
220220 }
221221
222222 instanceGroup , response , err := sess .CreateInstanceGroup (& instanceGroupOptions )
223- if err != nil {
223+ if err != nil || instanceGroup == nil {
224224 return fmt .Errorf ("Error Creating InstanceGroup: %s\n %s" , err , response )
225225 }
226226 d .SetId (* instanceGroup .ID )
@@ -258,7 +258,7 @@ func resourceIBMISInstanceGroupUpdate(d *schema.ResourceData, meta interface{})
258258 instanceGroupID := d .Id ()
259259 getInstanceGroupOptions := vpcv1.GetInstanceGroupOptions {ID : & instanceGroupID }
260260 instanceGroup , response , err := sess .GetInstanceGroup (& getInstanceGroupOptions )
261- if err != nil {
261+ if err != nil || instanceGroup == nil {
262262 return fmt .Errorf ("Error getting instance group: %s\n %s" , err , response )
263263 }
264264 oldList , newList := d .GetChange ("tags" )
@@ -342,7 +342,7 @@ func resourceIBMISInstanceGroupRead(d *schema.ResourceData, meta interface{}) er
342342 instanceGroupID := d .Id ()
343343 getInstanceGroupOptions := vpcv1.GetInstanceGroupOptions {ID : & instanceGroupID }
344344 instanceGroup , response , err := sess .GetInstanceGroup (& getInstanceGroupOptions )
345- if err != nil {
345+ if err != nil || instanceGroup == nil {
346346 if response != nil && response .StatusCode == 404 {
347347 d .SetId ("" )
348348 return nil
@@ -397,7 +397,7 @@ func resourceIBMISInstanceGroupDelete(d *schema.ResourceData, meta interface{})
397397 instanceGroupPatchModel := vpcv1.InstanceGroupPatch {}
398398
399399 instanceGroupPatchModel .MembershipCount = & zeroMembers
400- instanceGroupPatch , _ := instanceGroupPatchModel .AsPatch ()
400+ instanceGroupPatch , err := instanceGroupPatchModel .AsPatch ()
401401 if err != nil {
402402 return fmt .Errorf ("Error calling asPatch for ImagePatch: %s" , err )
403403 }
@@ -461,10 +461,11 @@ func waitForHealthyInstanceGroup(d *schema.ResourceData, meta interface{}, timeo
461461 Target : []string {HEALTHY },
462462 Refresh : func () (interface {}, string , error ) {
463463 instanceGroup , response , err := sess .GetInstanceGroup (& getInstanceGroupOptions )
464- log .Println ("Status : " , * instanceGroup .Status )
465- if err != nil {
464+ if err != nil || instanceGroup == nil {
466465 return nil , SCALING , fmt .Errorf ("Error Getting InstanceGroup: %s\n %s" , err , response )
467466 }
467+ log .Println ("Status : " , * instanceGroup .Status )
468+
468469 if * instanceGroup .Status == "" {
469470 return instanceGroup , SCALING , nil
470471 }
0 commit comments