{"action":"created","issue":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-vsphere/issues/392","repository_url":"https://api.github.com/repos/terraform-providers/terraform-provider-vsphere","labels_url":"https://api.github.com/repos/terraform-providers/terraform-provider-vsphere/issues/392/labels{/name}","comments_url":"https://api.github.com/repos/terraform-providers/terraform-provider-vsphere/issues/392/comments","events_url":"https://api.github.com/repos/terraform-providers/terraform-provider-vsphere/issues/392/events","html_url":"https://github.com/terraform-providers/terraform-provider-vsphere/issues/392","id":295619195,"number":392,"title":"Attach of a disk created via the virtual_disk resource fails ","user":{"login":"surajsub","id":2574487,"avatar_url":"https://avatars3.githubusercontent.com/u/2574487?v=4","gravatar_id":"","url":"https://api.github.com/users/surajsub","html_url":"https://github.com/surajsub","followers_url":"https://api.github.com/users/surajsub/followers","following_url":"https://api.github.com/users/surajsub/following{/other_user}","gists_url":"https://api.github.com/users/surajsub/gists{/gist_id}","starred_url":"https://api.github.com/users/surajsub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/surajsub/subscriptions","organizations_url":"https://api.github.com/users/surajsub/orgs","repos_url":"https://api.github.com/users/surajsub/repos","events_url":"https://api.github.com/users/surajsub/events{/privacy}","received_events_url":"https://api.github.com/users/surajsub/received_events","type":"User","site_admin":false},"labels":[{"id":620326258,"url":"https://api.github.com/repos/terraform-providers/terraform-provider-vsphere/labels/bug","name":"bug","color":"f7c6c7","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-02-08T18:30:26Z","updated_at":"2018-02-27T17:08:18Z","closed_at":null,"author_association":"NONE","body":"### Terraform Version\r\n0.10.7\r\n\r\n\r\n### vSphere Provider Version\r\n1.3\r\n\r\n\r\n### Affected Resource(s)\r\n- vsphere_virtual_machine\r\n\r\n\r\n\r\n\r\n### Terraform Configuration Files\r\nTemplate File \r\n===========\r\n\r\n```\r\n##################### Variables for Version 3.0. - Template Version V12 - V2###############################\r\n\r\nvariable \"name\" {\r\n\tdescription = \"Name of the Virtual Machine\"\r\n}\r\n\r\nvariable \"datacenter\" {\r\n\tdescription = \"Target vSphere datacenter for Virtual Machine creation\"\r\n}\r\n\r\n\r\nvariable \"vcpu\" {\r\n\tdescription = \"Number of Virtual CPU for the Virtual Machine\"\r\n\tdefault = 1\r\n}\r\n\r\nvariable \"num_of_cores_socket\" {\r\n\tdescription = \"Number of Cores per socket\"\r\n\t\r\n}\r\n\r\n\r\n\r\n\r\n\r\nvariable \"cluster\" {\r\n\tdescription = \"Target vSphere Cluster to host the Virtual Machine\"\r\n}\r\n\r\nvariable \"network_label\" {\r\n\tdescription = \"vSphere Port Group or Network label for Virtual Machine's vNIC\" \r\n}\r\n\r\nvariable \"ipv4_address\" {\r\n\tdescription = \"IPv4 address for vNIC configuration\"\r\n}\r\n\r\nvariable \"ipv4_gateway\" {\r\n\tdescription = \"IPv4 gateway for vNIC configuration\"\r\n}\r\n\r\nvariable \"ipv4_prefix_length\" {\r\n\tdescription = \"IPv4 Prefix length for vNIC configuration\"\r\n}\r\n\r\nvariable \"network_label_2\" {\r\n\tdescription = \"vSphere Port Group or Network label CFN\" \r\n}\r\n\r\nvariable \"cfn_ipv4_address\" {\r\n\tdescription = \"IPv4 address for CFN configuration\"\r\n}\r\n\r\nvariable \"cfn_ipv4_gateway\" {\r\n\tdescription = \"IPv4 gateway for CFN configuration\"\r\n}\r\n\r\nvariable \"cfn_ipv4_prefix_length\" {\r\n\tdescription = \"IPv4 Prefix length for CFN configuration\"\r\n}\r\n\r\n\r\nvariable \"storage\" {\r\n\tdescription = \"Data store or storage cluster name for target VMs disks\"\r\n}\r\n\r\nvariable \"logstorage\" {\r\n\tdescription = \"Data store or storage cluster name for target VMs disks\"\r\n}\r\n\r\nvariable \"shared_data_storage\"\r\n{\r\ndescription = \"Shared Data Storage to be used for SDB Disks\"\r\n}\r\n\r\n\r\n\r\n\r\nvariable \"data_disk_size\"\r\n{\r\n\r\ndescription = \"data disk size for sap\"\r\n}\r\n\r\nvariable \"log_disk_size\"\r\n{\r\n\r\ndescription = \"Log disk size for sap\"\r\n}\r\n\r\nvariable \"shared_disk_size\"\r\n{\r\n\r\ndescription = \"Shared Disk size for SAP\"\r\n}\r\n\r\nvariable \"vm_template\" {\r\n\tdescription = \"Source VM or Template label for cloning\"\r\n}\r\n\r\nvariable \"ssh_user\" {\r\n\tdescription = \"User to login to the vm\"\r\n}\r\n\r\n\r\nvariable \"ssh_user_password\" {\r\n\tdescription = \"Password to login to the vm\"\r\n}\r\n\r\nvariable \"allow_selfsigned_cert\" {\r\n    description = \"Communication with vsphere server with self signed certificate\"\r\n    default = true\r\n}\r\n\r\nvariable \"dns_suffixes\" {\r\n  description = \"Name resolution suffixes for the virtual network adapter\"\r\n\r\n}\r\n\r\nvariable \"user_public_key\" {\r\ndescription = \"User Key to login to the vm\"\r\n}\r\n\r\n\r\n\r\n\r\n        \r\n        \r\n############### Optinal settings in provider ##########\r\nprovider \"vsphere\" {\r\n    version = \"1.3\"\r\n    allow_unverified_ssl = \"${var.allow_selfsigned_cert}\"\r\n}\r\n \r\ndata \"vsphere_datacenter\" \"datacenter\" {\r\n  name = \"${var.datacenter}\"\r\n}\r\n\r\ndata \"vsphere_virtual_machine\" \"template\" {\r\n  name          = \"${var.vm_template}\"\r\n  datacenter_id = \"${data.vsphere_datacenter.datacenter.id}\"\r\n}\r\n\r\ndata \"vsphere_datastore\" \"datastore\" {\r\n  name          = \"${var.storage}\"\r\n  datacenter_id = \"${data.vsphere_datacenter.datacenter.id}\"\r\n}\r\n\r\ndata \"vsphere_datastore\" \"shared_datastore\" {\r\n  name          = \"${var.shared_data_storage}\"\r\n  datacenter_id = \"${data.vsphere_datacenter.datacenter.id}\"\r\n}\r\n\r\ndata \"vsphere_datastore\" \"datastore1\" {\r\n\r\n\tname = \"${var.logstorage}\"\r\n    datacenter_id = \"${data.vsphere_datacenter.datacenter.id}\"\r\n    }\r\n\r\ndata \"vsphere_resource_pool\" \"pool\" {\r\n  name          = \"${var.cluster}\"\r\n  datacenter_id = \"${data.vsphere_datacenter.datacenter.id}\"\r\n}\r\n\r\ndata \"vsphere_network\" \"network\" {\r\n  name          = \"${var.network_label}\"\r\n  datacenter_id = \"${data.vsphere_datacenter.datacenter.id}\"\r\n}\r\n\r\n\r\n################## Resources ###############################\r\n\r\nresource \"vsphere_virtual_disk\" \"disk_1\" {\r\n  \tvmdk_path = \"sapvhana.1.vmdk\"\r\n    size = 25\r\n    datacenter = \"${var.datacenter}\"\r\n    datastore = \"${var.shared_data_storage}\"\r\n    type         = \"thin\"\r\n  \r\n  }\r\n##\r\nresource \"vsphere_virtual_machine\" \"vm_1\" {\r\n  name   = \"${var.name}\"\r\n  resource_pool_id = \"${data.vsphere_resource_pool.pool.id}\"\r\n  datastore_id     = \"${data.vsphere_datastore.datastore.id}\"\r\n  num_cpus   = \"${var.vcpu}\"\r\n  memory = \"${var.memory*1024}\"\r\n  memory_reservation = \"${var.memory*1024}\"\r\n  guest_id = \"${data.vsphere_virtual_machine.template.guest_id}\"\r\n  scsi_controller_count  = 4\r\n  num_cores_per_socket = \"${var.num_of_cores_socket}\"\r\n\r\n  network_interface {\r\n      network_id = \"${data.vsphere_network.network.id}\"\r\n  }\r\n  \r\n  network_interface {\r\n      network_id = \"${data.vsphere_network.imz_network.id}\"\r\n  }\r\n\r\n  disk {\r\n    name = \"${var.name}.vmdk\"\r\n    size = \"${data.vsphere_virtual_machine.template.disks.0.size}\"\r\n    eagerly_scrub    = \"${data.vsphere_virtual_machine.template.disks.0.eagerly_scrub}\"\r\n    thin_provisioned = \"${data.vsphere_virtual_machine.template.disks.0.thin_provisioned}\"\r\n  }\r\n  \r\n  disk {\r\n  \t## This will be sdb\r\n  \tname = \"${var.name}.1.vmdk\"\r\n    size = 112\r\n    unit_number = 1\r\n    datastore_id = \"${data.vsphere_datastore.datastore.id}\"\r\n    \r\n\t}\r\n  \r\n  disk { \r\n  \tname = \"${var.name}.2.vmdk\"\r\n    size = \"${var.data_disk_size}\"\r\n    unit_number = 15\r\n    datastore_id = \"${data.vsphere_datastore.datastore1.id}\"\r\n    disk_mode = \"independent_persistent\"\r\n\t}\r\n    \r\n disk {\r\n  \tname = \"${var.name}.3.vmdk\"\r\n    size = \"${var.log_disk_size}\"\r\n    unit_number = 30\r\n    datastore_id = \"${data.vsphere_datastore.datastore1.id}\"\r\n    disk_mode = \"independent_persistent\"\r\n\t}\r\n    \r\n disk {\r\n  \tname = \"${var.name}.4.vmdk\"\r\n    size = \"${var.shared_disk_size}\"\r\n    unit_number = 31\r\n    datastore_id = \"${data.vsphere_datastore.datastore1.id}\"\r\n    disk_mode = \"independent_persistent\"\r\n\t}   \r\n    \r\ndisk \r\n{ ## This will be the disk that we created prior\r\n\tattach = true\r\n\tpath = \"${vsphere_virtual_disk.disk_1.vmdk_path}\"\r\n\tlabel = \"diskshared\"\r\n\tunit_number = 2\r\n\tdatastore_id = \"${data.vsphere_datastore.shared_datastore.id}\"\r\n\tdisk_sharing = \"sharingMultiWriter\"\r\n\t disk_mode = \"independent_persistent\"\r\n\t\r\n\t}\r\n   \r\n        \r\n      # Specify the ssh connection\r\n  connection {\r\n  \ttype = \"ssh\"\r\n    user        = \"${var.ssh_user}\"\r\n    password    = \"${var.ssh_user_password}\" \r\n    host       =       \"${var.ipv4_address}\"\r\n    \r\n  }   \r\n \r\n  clone {\r\n    template_uuid = \"${data.vsphere_virtual_machine.template.id}\"\r\n\r\n    customize {\r\n    \r\n      timeout = \"120\"\r\n      linux_options {\r\n        host_name = \"${var.name}\"\r\n        domain    = \"${var.dns_suffixes}\"\r\n      }\r\n    \r\n\r\n      network_interface {\r\n        ipv4_address = \"${var.ipv4_address}\"\r\n        ipv4_netmask = \"${var.ipv4_prefix_length}\"\r\n      }\r\n      \r\n      \r\n      network_interface {\r\n        ipv4_address = \"${var.cfn_ipv4_address}\"\r\n        ipv4_netmask = \"${var.cfn_ipv4_prefix_length}\"\r\n      }\r\n\r\n      ipv4_gateway = \"${var.ipv4_gateway}\"\r\n      \r\n     \r\n      \r\n            \r\n    dns_server_list     = [\"8.8.8.8\"]\r\n    dns_suffix_list     = [\" mydomain.com\"]\r\n    \r\n    }\r\n    \r\n   \r\n  }\r\n}\r\n\r\noutput \"ipv4_address\" {\r\n  value = \"${var.ipv4_address}\"\r\n}\r\noutput \"disk_name\" {\r\n  value = \"${vsphere_virtual_machine.vm_1.disk.name}\"\r\n}\r\n\r\n```\r\n\r\n### Debug Output\r\nhttps://gist.github.com/surajsub/2fa41e991ccfee1d1a21d68eadad8442\r\n\r\n\r\n\r\n### Expected Behavior\r\n\r\nWhat should have happened?\r\n\r\nTF should have attached the created disk to the vm\r\n\r\n### Actual Behavior\r\n\r\nWhat actually happened?\r\n\r\nTerraform errors out with the failure attached in the gist log.\r\n### Steps to Reproduce\r\n\r\nCreate a disk with the virtual_disk_resource and try to attach it as part of the create vm\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-vsphere/issues/comments/368952109","html_url":"https://github.com/terraform-providers/terraform-provider-vsphere/issues/392#issuecomment-368952109","issue_url":"https://api.github.com/repos/terraform-providers/terraform-provider-vsphere/issues/392","id":368952109,"user":{"login":"surajsub","id":2574487,"avatar_url":"https://avatars3.githubusercontent.com/u/2574487?v=4","gravatar_id":"","url":"https://api.github.com/users/surajsub","html_url":"https://github.com/surajsub","followers_url":"https://api.github.com/users/surajsub/followers","following_url":"https://api.github.com/users/surajsub/following{/other_user}","gists_url":"https://api.github.com/users/surajsub/gists{/gist_id}","starred_url":"https://api.github.com/users/surajsub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/surajsub/subscriptions","organizations_url":"https://api.github.com/users/surajsub/orgs","repos_url":"https://api.github.com/users/surajsub/repos","events_url":"https://api.github.com/users/surajsub/events{/privacy}","received_events_url":"https://api.github.com/users/surajsub/received_events","type":"User","site_admin":false},"created_at":"2018-02-27T17:08:18Z","updated_at":"2018-02-27T17:08:18Z","author_association":"NONE","body":"Ok - let me disable those two options and try it ."}}
{"actor":{"display_login":"surajsub"}}