diff --git a/azurestack/resource_arm_virtual_machine_scale_set.go b/azurestack/resource_arm_virtual_machine_scale_set.go index 3f3299cff..20bc0b644 100644 --- a/azurestack/resource_arm_virtual_machine_scale_set.go +++ b/azurestack/resource_arm_virtual_machine_scale_set.go @@ -161,7 +161,7 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { "admin_password": { Type: schema.TypeString, - Required: true, + Optional: true, Sensitive: true, ValidateFunc: validation.NoZeroValues, }, @@ -861,22 +861,28 @@ func flattenAzureRmVirtualMachineScaleSetIdentity(identity *compute.VirtualMachi func flattenAzureRmVirtualMachineScaleSetOsProfileLinuxConfig(config *compute.LinuxConfiguration) []interface{} { result := make(map[string]interface{}) - result["disable_password_authentication"] = *config.DisablePasswordAuthentication - if config.SSH != nil && len(*config.SSH.PublicKeys) > 0 { - ssh_keys := make([]map[string]interface{}, 0, len(*config.SSH.PublicKeys)) - for _, i := range *config.SSH.PublicKeys { - key := make(map[string]interface{}) - key["path"] = *i.Path + if v := config.DisablePasswordAuthentication; v != nil { + result["disable_password_authentication"] = *v + } + + if ssh := config.SSH; ssh != nil { + if keys := ssh.PublicKeys; keys != nil { + ssh_keys := make([]map[string]interface{}, 0, len(*keys)) - if i.KeyData != nil { - key["key_data"] = *i.KeyData + for _, i := range *keys { + key := make(map[string]interface{}) + if i.Path != nil { + key["path"] = *i.Path + } + if i.KeyData != nil { + key["key_data"] = *i.KeyData + } + ssh_keys = append(ssh_keys, key) } - ssh_keys = append(ssh_keys, key) + result["ssh_keys"] = ssh_keys } - - result["ssh_keys"] = ssh_keys } return []interface{}{result}