diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine.go b/builtin/providers/azurerm/resource_arm_virtual_machine.go index 080f423d0..5868d11ac 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine.go @@ -927,9 +927,13 @@ func expandAzureRmVirtualMachineOsProfileLinuxConfig(d *schema.ResourceData) (*c } linuxKeys := linuxConfig["ssh_keys"].([]interface{}) - sshPublicKeys := make([]compute.SSHPublicKey, 0, len(linuxKeys)) + sshPublicKeys := []compute.SSHPublicKey{} for _, key := range linuxKeys { - sshKey := key.(map[string]interface{}) + + sshKey, ok := key.(map[string]interface{}) + if !ok { + continue + } path := sshKey["path"].(string) keyData := sshKey["key_data"].(string)