Skip to content

Commit

Permalink
VMSS admin_password is now optional
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Oct 5, 2018
1 parent e734dc4 commit 14731f4
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions azurestack/resource_arm_virtual_machine_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {

"admin_password": {
Type: schema.TypeString,
Required: true,
Optional: true,
Sensitive: true,
ValidateFunc: validation.NoZeroValues,
},
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 14731f4

Please sign in to comment.