Error: Unsupported block type

Hi team,

I get this error when I run the command

terraform.exe validate

Error: Unsupported block type

on main.tf line 62:
62: clone {

Blocks of type “clone” are not expected here.

snippet

clone {
template_uuid = “data.vsphere_virtual_machine.template.id”

customize {
  windows_options {
    computer_name    = "var.server_name"
    admin_password   = "var.winadmin_password"
    auto_logon       = true
    auto_logon_count = 1
    #join_domain = "var.join_domain"
    #domain_admin_user = "var.domain_admin_user"
    #domain_admin_password = "domain_admin_password"

    # Run these commands after autologon. Configure WinRM access and disable windows firewall.
    run_once_command_list = [
      "winrm quickconfig -force",
      "winrm set winrm/config @{MaxEnvelopeSizekb=\"100000\"}",
      "winrm set winrm/config/Service @{AllowUnencrypted=\"true\"}",
      "winrm set winrm/config/Service/Auth @{Basic=\"true\"}",
      "netsh advfirewall set allprofiles state off",
    ]
  }

I don’t know a lot about the vsphere provider specifically, but it looks as if the clone block must be contained within a parent “resource” block. It’s not evident from the information provided here whether that’s the case or not.

Thanks Petros,

It is part of the resource

resource “vsphere_virtual_machine” “vmname” {
name = “${var.vmname}”
resource_pool_id = “data.vsphere_resource_pool.pool.id”
datastore_id = “data.vsphere_datastore.datastore.id”

guest_id = “data.vsphere_virtual_machine.template.guest_id”
memory = “${var.memory}”
wait_for_guest_net_timeout = “var.timeout”

network_interface {
network_id = “data.vsphere_network.network.id”
}

disk {
name = “var.diskname”
size = “var.size”
}

cdrom {
datastore_id = “data.vsphere_datastore.iso_datastore.id”
path = “var.iso”
}
}

clone {
template_uuid = “data.vsphere_virtual_machine.template.id”

customize {
  windows_options {
    computer_name    = "var.server_name"
    admin_password   = "var.winadmin_password"
    auto_logon       = true
    auto_logon_count = 1
    #join_domain = "var.join_domain"
    #domain_admin_user = "var.domain_admin_user"
    #domain_admin_password = "domain_admin_password"

    # Run these commands after autologon. Configure WinRM access and disable windows firewall.
    run_once_command_list = [
      "winrm quickconfig -force",
      "winrm set winrm/config @{MaxEnvelopeSizekb=\"100000\"}",
      "winrm set winrm/config/Service @{AllowUnencrypted=\"true\"}",
      "winrm set winrm/config/Service/Auth @{Basic=\"true\"}",
      "netsh advfirewall set allprofiles state off",
    ]
  }

  network_interface {
    ipv4_address    = "var.IP_address"
    ipv4_netmask    = "var.netmask"
    dns_server_list = ["var.dns_server"]
  }

  ipv4_gateway = "var.def_gw"
}

}
}

I am having a sligh change with the template syntax, do i need an existing template