Skip to content

Commit

Permalink
resolved bug on import of instance
Browse files Browse the repository at this point in the history
  • Loading branch information
uibm authored and hkantare committed Sep 24, 2021
1 parent ec5d9d2 commit e8091d2
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions ibm/resource_ibm_is_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,11 @@ func resourceIBMISInstance() *schema.Resource {
},

isEnableCleanDelete: {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Enables stopping of instance before deleting and waits till deletion is complete",
Type: schema.TypeBool,
Optional: true,
Default: true,
DiffSuppressFunc: suppressEnableCleanDelete,
Description: "Enables stopping of instance before deleting and waits till deletion is complete",
},

isInstanceVolumeAttachments: {
Expand Down Expand Up @@ -355,10 +356,11 @@ func resourceIBMISInstance() *schema.Resource {
},

isInstanceUserData: {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Description: "User data given for the instance",
Type: schema.TypeString,
ForceNew: true,
DiffSuppressFunc: suppressUserData,
Optional: true,
Description: "User data given for the instance",
},

isInstanceImage: {
Expand Down Expand Up @@ -2313,6 +2315,22 @@ func resourceIbmIsInstanceInstanceDiskToMap(instanceDisk vpcv1.InstanceDisk) map
return instanceDiskMap
}

func suppressEnableCleanDelete(k, old, new string, d *schema.ResourceData) bool {
// During import
if old == "" && !d.IsNewResource() {
return true
}
return false
}

func suppressUserData(k, old, new string, d *schema.ResourceData) bool {
// During import
if old == "" && !d.IsNewResource() {
return true
}
return false
}

func resourceIbmIsInstanceInstancePlacementToMap(instancePlacement vpcv1.InstancePlacementTarget) map[string]interface{} {
instancePlacementMap := map[string]interface{}{}

Expand Down

0 comments on commit e8091d2

Please sign in to comment.