diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine.go b/builtin/providers/azurerm/resource_arm_virtual_machine.go index 93e49fa27..4145e8f02 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine.go @@ -277,7 +277,7 @@ func resourceArmVirtualMachine() *schema.Resource { Required: true, }, "ssh_keys": &schema.Schema{ - Type: schema.TypeSet, + Type: schema.TypeList, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -291,7 +291,6 @@ func resourceArmVirtualMachine() *schema.Resource { }, }, }, - Set: resourceArmVirtualMachineStorageOsProfileLinuxConfigSshKeyHash, }, }, }, @@ -491,7 +490,7 @@ func resourceArmVirtualMachineRead(d *schema.ResourceData, meta interface{}) err } if resp.Properties.OsProfile.LinuxConfiguration != nil { - if err := d.Set("os_profile_linux_config", schema.NewSet(resourceArmVirtualMachineStorageOsProfileLinuxConfigHash, flattenAzureRmVirtualMachineOsProfileLinuxConfiguration(resp.Properties.OsProfile.LinuxConfiguration))); err != nil { + if err := d.Set("os_profile_linux_config", flattenAzureRmVirtualMachineOsProfileLinuxConfiguration(resp.Properties.OsProfile.LinuxConfiguration)); err != nil { return fmt.Errorf("[DEBUG] Error setting Virtual Machine Storage OS Profile Linux Configuration: %#v", err) } } @@ -586,17 +585,6 @@ func resourceArmVirtualMachineStorageOsDiskHash(v interface{}) int { return hashcode.String(buf.String()) } -func resourceArmVirtualMachineStorageOsProfileLinuxConfigSshKeyHash(v interface{}) int { - var buf bytes.Buffer - m := v.(map[string]interface{}) - buf.WriteString(fmt.Sprintf("%s-", m["path"].(string))) - if m["key_data"] != nil { - buf.WriteString(fmt.Sprintf("%s-", m["key_data"].(string))) - } - - return hashcode.String(buf.String()) -} - func resourceArmVirtualMachineStorageOsProfileLinuxConfigHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) @@ -747,15 +735,15 @@ func flattenAzureRmVirtualMachineOsProfileWindowsConfiguration(config *compute.W } func flattenAzureRmVirtualMachineOsProfileLinuxConfiguration(config *compute.LinuxConfiguration) []interface{} { - result := map[string]interface{}{ - "disable_password_authentication": *config.DisablePasswordAuthentication, - } + + 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)) + ssh_keys := make([]map[string]interface{}, len(*config.SSH.PublicKeys)) for _, i := range *config.SSH.PublicKeys { key := make(map[string]interface{}) - key["name"] = *i.Path + key["path"] = *i.Path if i.KeyData != nil { key["key_data"] = *i.KeyData @@ -910,7 +898,7 @@ func expandAzureRmVirtualMachineOsProfileLinuxConfig(d *schema.ResourceData) (*c DisablePasswordAuthentication: &disablePasswordAuth, } - linuxKeys := linuxConfig["ssh_keys"].(*schema.Set).List() + linuxKeys := linuxConfig["ssh_keys"].([]interface{}) sshPublicKeys := make([]compute.SSHPublicKey, 0, len(linuxKeys)) for _, key := range linuxKeys { sshKey := key.(map[string]interface{}) diff --git a/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown b/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown index d2b6233bf..892f8ba91 100644 --- a/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown +++ b/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown @@ -175,7 +175,9 @@ For more information on the different example configurations, please check out t `os_profile_linux_config` supports the following: * `disable_password_authentication` - (Required) Specifies whether password authentication should be disabled. -* `ssh_keys` - (Optional) Specifies a collection of `path` and `key_data` to be placed on the virtual machine. +* `ssh_keys` - (Optional) Specifies a collection of `path` and `key_data` to be placed on the virtual machine. + +~> **Note:** Please note that the only allowed `path` is `/home//.ssh/authorized_keys` due to a limitation of Azure_ `os_profile_secrets` supports the following: