diff --git a/terraform/providers/vsphereprivate/resource_vsphereprivate_import_ova.go b/terraform/providers/vsphereprivate/resource_vsphereprivate_import_ova.go index c0b89836ada..cd553aff0c6 100644 --- a/terraform/providers/vsphereprivate/resource_vsphereprivate_import_ova.go +++ b/terraform/providers/vsphereprivate/resource_vsphereprivate_import_ova.go @@ -102,8 +102,8 @@ func resourceVSpherePrivateImportOva() *schema.Resource { }, "disk_type": { Type: schema.TypeString, - Description: "The name of the disk provisioning, for e.g eagerZeroedThick or thin, by default it will be thick.", - Required: true, + Description: "The name of the disk provisioning type, valid values are thin, thick and eagerZeroedThick.", + Optional: true, ForceNew: true, }, }, @@ -361,21 +361,23 @@ func resourceVSpherePrivateImportOvaCreate(d *schema.ResourceData, meta interfac Network: importOvaParams.Network.Reference(), }} - var diskType types.OvfCreateImportSpecParamsDiskProvisioningType - - if d.Get("disk_type") == "thin" { - diskType = types.OvfCreateImportSpecParamsDiskProvisioningTypeThin - } else if d.Get("disk_type") == "eagerZeroedThick" { - diskType = types.OvfCreateImportSpecParamsDiskProvisioningTypeEagerZeroedThick - } else { - diskType = types.OvfCreateImportSpecParamsDiskProvisioningTypeThick - } - // This is a very minimal spec for importing - // an OVF. + // This is a very minimal spec for importing an OVF. cisp := types.OvfCreateImportSpecParams{ - DiskProvisioning: string(diskType), - EntityName: d.Get("name").(string), - NetworkMapping: networkMappings, + EntityName: d.Get("name").(string), + NetworkMapping: networkMappings, + } + + switch diskType := d.Get("disk_type"); diskType { + case "": + // Disk provisioning type will be set according to the default storage policy of vsphere. + case "thin": + cisp.DiskProvisioning = string(types.OvfCreateImportSpecParamsDiskProvisioningTypeThin) + case "thick": + cisp.DiskProvisioning = string(types.OvfCreateImportSpecParamsDiskProvisioningTypeThick) + case "eagerZeroedThick": + cisp.DiskProvisioning = string(types.OvfCreateImportSpecParamsDiskProvisioningTypeEagerZeroedThick) + default: + return errors.Errorf("Disk provisioning type %q is not supported.", diskType) } m := ovf.NewManager(client)