diff --git a/main.tf b/main.tf index d620cb9..4047be6 100644 --- a/main.tf +++ b/main.tf @@ -87,10 +87,10 @@ resource "azurerm_virtual_machine" "vm-linux" { disable_password_authentication = var.enable_ssh_key dynamic ssh_keys { - for_each = var.enable_ssh_key ? [var.ssh_key] : [] + for_each = var.enable_ssh_key ? var.ssh_keys : [] content { path = "/home/${var.admin_username}/.ssh/authorized_keys" - key_data = file(var.ssh_key) + key_data = file(ssh_keys.value) } } } diff --git a/variables.tf b/variables.tf index 238e73a..a7af659 100644 --- a/variables.tf +++ b/variables.tf @@ -26,10 +26,10 @@ variable "admin_password" { default = "" } -variable "ssh_key" { - description = "Path to the public key to be used for ssh access to the VM. Only used with non-Windows vms and can be left as-is even if using Windows vms. If specifying a path to a certification on a Windows machine to provision a linux vm use the / in the path versus backslash. e.g. c:/home/id_rsa.pub." - type = string - default = "~/.ssh/id_rsa.pub" +variable "ssh_keys" { + description = "Paths to the public key files to be used for ssh access to the VM. Only used with non-Windows vms and can be left as-is even if using Windows vms. If specifying a path to a certification on a Windows machine to provision a linux vm use the / in the path versus backslash. e.g. c:/home/id_rsa.pub." + type = list(string) + default = ["~/.ssh/id_rsa.pub"] } variable "remote_port" {