Unable to get memory or num_cpus from template

While trying to allocate memory and num_cpus for a virtual machine, I am trying to extract the memory and num_cpus from the template. But I am getting an error while trying to do so.
Here is my resource:

resource "vsphere_virtual_machine" "vm" {

  count = var.vm-count

  name = "${var.vm-name}-${count.index + 1}"

  resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id

  datastore_id = data.vsphere_datastore.datastore.id

  folder = var.vm-folder

  num_cpus = data.vsphere_virtual_machine.template.num_cpus

  memory = data.vsphere_virtual_machine.template.memory

  guest_id = data.vsphere_virtual_machine.template.guest_id

  scsi_type = data.vsphere_virtual_machine.template.scsi_type

  firmware = data.vsphere_virtual_machine.template.firmware

  network_interface {

    network_id = data.vsphere_network.network.id

    adapter_type = data.vsphere_virtual_machine.template.network_interface_types[0]

  }

  disk {

      label            = "disk0"

      size             = data.vsphere_virtual_machine.template.disks.0.size

      eagerly_scrub    = data.vsphere_virtual_machine.template.disks.0.eagerly_scrub

      thin_provisioned = data.vsphere_virtual_machine.template.disks.0.thin_provisioned

    }

  clone {

    template_uuid = data.vsphere_virtual_machine.template.id

    customize {

        windows_options {

          auto_logon_count = 2

          computer_name = "HarshitDev"

          organization_name = "Philips"

        }

      }

  }

}

And here is the error I am getting:

Error: Unsupported attribute

  on main.tf line 39, in resource "vsphere_virtual_machine" "vm":
  39: num_cpus = data.vsphere_virtual_machine.template.num_cpus

This object has no argument, nested block, or exported attribute named
"num_cpus".


Error: Unsupported attribute

  on main.tf line 40, in resource "vsphere_virtual_machine" "vm":
  40: memory = data.vsphere_virtual_machine.template.memory

This object has no argument, nested block, or exported attribute named
"memory".