This is my SSH public keys setting under linux/main.tf
:
resource "azurerm_linux_virtual_machine" "mytfvm" {
name = "${var.name}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
availability_set_id = "${var.availability_set_id}"
network_interface_ids = ["${azurerm_network_interface.nic.id}"]
size = "${var.vm_size}"
computer_name = "${var.name}"
admin_username = "${var.admin_username}"
disable_password_authentication = true
custom_data = "${var.cloud_config}"
admin_ssh_key {
// key_data = "${var.ssh_key}"
// path = "/home/${var.admin_username}/.ssh/authorized_keys"
username = "azureuser"
public_key = tls_private_key.example_ssh.public_key_openssh
}
os_disk {
name = "${var.name}-os"
caching = "ReadWrite"
storage_account_type = "${var.storage_type}"
}
It is causing the following problems:
module.linux.azurerm_linux_virtual_machine.mytfvm: Creating...
╷
│ Error: creating Linux Virtual Machine: (Name "ubuntu" / Resource Group "paas"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="Destination path for SSH public keys is currently limited to its default value /home/foo/.ssh/authorized_keys due to a known issue in Linux provisioning agent." Target="linuxConfiguration.ssh.publicKeys.path"
│
│ with module.linux.azurerm_linux_virtual_machine.mytfvm,
│ on linux/main.tf line 78, in resource "azurerm_linux_virtual_machine" "mytfvm":
│ 78: resource "azurerm_linux_virtual_machine" "mytfvm" {
│
The admin_ssh_key
setting is copied directly from Quickstart: Use Terraform to create a Linux VM - Azure Virtual Machines | Microsoft Learn, which I’ve made it working. Why it works there but not in my linux module?
How to fix it?