Azure Terraform Erros and Solution

│ Error: file provisioner error
│
│   with azurerm_linux_virtual_machine.myterraformvm,
│   on azure_resources.tf line 171, in resource "azurerm_linux_virtual_machine" "myterraformvm":
│  171:         provisioner "file" {
│
│ host for provisioner cannot be empty
╵
PS E:\terraform\azure4> terraform destroy
╷
│ Error: Unsupported argument
│
│   on azure_resources.tf line 172, in resource "azurerm_linux_virtual_machine" "myterraformvm":
│  172:                 host = "${azurerm_public_ip.myterraformpublicip.fqdn}"
│
│ An argument named "host" is not expected here.


│ Error: Incorrect attribute value type
│
│   on azure_resources.tf line 163, in resource "azurerm_linux_virtual_machine" "myterraformvm":
│  163:         host = self.public_ip_addresses
│     ├────────────────
│     │ self.public_ip_addresses is list of string with 1 element
│
│ Inappropriate value for attribute "host": string required.


connection {
        host = self.public_ip_addresses
        user = "azureuser"
        type = "ssh"
        private_key = "${file("~/.ssh/id_rsa")}"
        timeout = "4m"
        agent = true
    }

connection {
    type        = "ssh"
    user        = "ec2-user"
    private_key = file("~/.ssh/terraform")
    host        = self.public_ip
  }


│ Error: file provisioner error
│
│   with azurerm_linux_virtual_machine.myterraformvm,
│   on azure_resources.tf line 171, in resource "azurerm_linux_virtual_machine" "myterraformvm":
│  171:         provisioner "file" {
│
│ SSH agent requested but Pageant not running

Solution in Windows - Make agent = false

connection {
        host = self.public_ip_addresses
        user = "azureuser"
        type = "ssh"
        private_key = "${file("~/.ssh/id_rsa")}"
        timeout = "4m"
        agent = false
    }



│ Error: file provisioner error
│
│   with azurerm_linux_virtual_machine.myterraformvm,
│   on azure_resources.tf line 171, in resource "azurerm_linux_virtual_machine" "myterraformvm":
│  171:         provisioner "file" {
│
│ timeout - last error: dial tcp: lookup self.public_ip_address: no such host
╵