# Unable to get memory or num\_cpus from template

**URL:** <https://discuss.hashicorp.com/t/unable-to-get-memory-or-num-cpus-from-template/7678>\
**Category:** Terraform\
**Tags:** vsphere\
**Created:** [April 15, 2020, 2:28pm UTC](https://discuss.hashicorp.com/t/unable-to-get-memory-or-num-cpus-from-template/7678 "2020-04-15T14:28:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![harshit0921](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/harshit0921/32/5983_2.png) [@harshit0921](https://discuss.hashicorp.com/u/harshit0921)\
**Post date:** [April 15, 2020, 2:28pm UTC](https://discuss.hashicorp.com/t/unable-to-get-memory-or-num-cpus-from-template/7678/1 "2020-04-15T14:28:22Z")

</div>

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".
```
