Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_virtual_machine_scale_set: make os_profile.0.admin_password property optional #1958

Merged
merged 1 commit into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions azurerm/resource_arm_virtual_machine_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {
Read: resourceArmVirtualMachineScaleSetRead,
Update: resourceArmVirtualMachineScaleSetCreate,
Delete: resourceArmVirtualMachineScaleSetDelete,

Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Expand Down Expand Up @@ -163,7 +164,7 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {

"admin_password": {
Type: schema.TypeString,
Required: true,
Optional: true,
Sensitive: true,
ValidateFunc: validation.NoZeroValues,
},
Expand Down Expand Up @@ -973,22 +974,30 @@ 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))
for _, i := range *keys {
key := make(map[string]interface{})

if i.KeyData != nil {
key["key_data"] = *i.KeyData
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
2 changes: 0 additions & 2 deletions azurerm/resource_arm_virtual_machine_scale_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,6 @@ resource "azurerm_virtual_machine_scale_set" "test" {
os_profile {
computer_name_prefix = "prefix"
admin_username = "ubuntu"
admin_password = "password"
custom_data = "custom data!"
}

Expand Down Expand Up @@ -2168,7 +2167,6 @@ resource "azurerm_virtual_machine_scale_set" "test" {
os_profile {
computer_name_prefix = "prefix"
admin_username = "ubuntu"
admin_password = "password"
custom_data = "custom data!"
}

Expand Down