You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vote on this issue by adding a 👍 reaction to the original issue initial description to help the maintainers prioritize.
Do not leave "+1" or other comments that do not add relevant information or questions.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.
Terraform
1.7.1
Terraform Provider
hashicorp/vsphere
VMware vSphere
8.0.3.00400
Description
Not sure if my tf version has anything to do with this but can try if it truly is related.
It would seem that the following is true:
I can create a vsphere_virtual_machine resource fine
I can create the vsphere_virtual_disk resource fine
What I cannot do is create them, then attach them in the same terraform apply.
For example, I am creating the vsphere_virtual_machine with a single boot disk and a secondary disk that is created separately from the vm....hence the vsphere_virtual_disk
Scenario 1: When I try to include that secondary disk as an attachment to the vm, when the virtual machine is initially created, it will not attach as it keeps asking about the datastore_id even though I am explicitly setting it.
Scenario 2: When I try to create the vsphere_virtual_disk and the vsphere_virtual_machine independently but do not attach the first time through, it creates all resources. From there I can re-enable the code to attach the volume in which the vm then allows the volume to be attached to the vm as intended.
Hopefully these 2 scenarios make sense. As you can imagine I would quite like for scenario 1 to work.
These are not being created presently on a clustered datastore.
I'm sorry I cannot provide full code but I followed the documentation and that code really is enough just need to attach the volume.
resource "vsphere_virtual_machine" "vm1" {
------------------------
#ifI comment this out, do a terraform apply, then re-enable this code it attaches to the vm.
disk{
attach = true
label = "disk1"
path = vsphere_virtual_disk.data.vmdk_path
datastore_id = data.vsphere_datastore.datastore.id
disk_mode = "persistent"
unit_number = 1
}
--------
}
resource "vsphere_virtual_disk" "data" {
size = var.persistentDisk.size
type = "thin"
vmdk_path = "/datadisks/${var.vm.vm_hostname}-${var.persistentDisk.name}.vmdk"
create_directories = true
datacenter = data.vsphere_datacenter.datacenter.name
datastore = data.vsphere_datastore.datastore.name
}
Debug Output
would rather not post what was requested:
│ Error: disk.1: datastore_id for disk "disk1" is required when attach is set
│
│ with module.vsphere-vms["hostA"].vsphere_virtual_machine.vm,
│ on .terraform/modules/vsphere-vms/vm.tf line 1, in resource "vsphere_virtual_machine" "vm":
│ 1: resource "vsphere_virtual_machine" "vm" {
│
Panic Output
No response
Expected Behavior
Allow both the vm and the disk to be created with the disk attached on first runthrough.
Actual Behavior
Receive error about missing a datastore_id even though it's been provided.
Steps to Reproduce
Use document sample code to create a vm and disk but DO include a secondary disk as an attached disk. Do not run without as it will create a vm and disk separately fine.
Environment Details
No response
Screenshots
No response
References
No response
The text was updated successfully, but these errors were encountered:
asteriskie
changed the title
REPLACE WITH A SHORT DESCRIPTION
Issue with VirtualMachine and VirtualDisk attachment at creation and Use as secondary disk during same apply.
Nov 25, 2024
Community Guidelines
Terraform
1.7.1
Terraform Provider
hashicorp/vsphere
VMware vSphere
8.0.3.00400
Description
Not sure if my tf version has anything to do with this but can try if it truly is related.
It would seem that the following is true:
I can create a vsphere_virtual_machine resource fine
I can create the vsphere_virtual_disk resource fine
What I cannot do is create them, then attach them in the same
terraform apply
.For example, I am creating the vsphere_virtual_machine with a single boot disk and a secondary disk that is created separately from the vm....hence the vsphere_virtual_disk
Scenario 1: When I try to include that secondary disk as an attachment to the vm, when the virtual machine is initially created, it will not attach as it keeps asking about the datastore_id even though I am explicitly setting it.
Scenario 2: When I try to create the vsphere_virtual_disk and the vsphere_virtual_machine independently but do not attach the first time through, it creates all resources. From there I can re-enable the code to attach the volume in which the vm then allows the volume to be attached to the vm as intended.
Hopefully these 2 scenarios make sense. As you can imagine I would quite like for scenario 1 to work.
These are not being created presently on a clustered datastore.
I'm sorry I cannot provide full code but I followed the documentation and that code really is enough just need to attach the volume.
Affected Resources or Data Sources
resource/vsphere_virtual_disk
resource /vshpere_virtual_machine
Terraform Configuration
Debug Output
would rather not post what was requested:
Panic Output
No response
Expected Behavior
Allow both the vm and the disk to be created with the disk attached on first runthrough.
Actual Behavior
Receive error about missing a datastore_id even though it's been provided.
Steps to Reproduce
Use document sample code to create a vm and disk but DO include a secondary disk as an attached disk. Do not run without as it will create a vm and disk separately fine.
Environment Details
No response
Screenshots
No response
References
No response
The text was updated successfully, but these errors were encountered: