Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Creating a Datacenter, then using it as the location to create a new folder, doesn't seem to work #563

Closed
kbpease opened this issue Jul 3, 2018 · 1 comment
Labels
bug Type: Bug

Comments

@kbpease
Copy link

kbpease commented Jul 3, 2018

Edit: fixed link to gist containing debug/failure output below

If I create a datacenter in an empty vCenter, then attempt to place a vsphere_folder inside of that created datacenter, my apply fails with an error message:

vsphere_folder.terraform: cannot locate datacenter: could not find datacenter with id: dc: ServerFaultCode: The object 'vim.Datacenter:dc' has already been deleted or has not been completely created.

From my reading of the provider docs, this operation SHOULD be supported, but it seems as if ${vsphere_datacenter.dc.id} is resolving to the name of the datacenter, rather than the id.

Terraform Version

Terraform v0.11.7

vSphere Provider Version

provider.vsphere v1.6.0

Affected Resource(s)

  • vsphere_datacenter
  • vsphere_folder

Terraform Configuration Files

provider "vsphere" {
  user                 = "${var.vc_username}"
  password             = "${var.vc_password}"
  vsphere_server       = "${var.vc_fqdn}"
  allow_unverified_ssl = true
}
resource "vsphere_datacenter" "dc" {
  name = "dc"
}
resource "vsphere_folder" "terraform" {
  path = "Terraform"
  type = "vm"
  datacenter_id = "${vsphere_datacenter.dc.id}"
}

Debug Output

https://gist.github.com/kbpease/ade8c025b443368f1c05a99398bbfbf8

Expected Behavior

In an empty vCenter (esxi 6.5), a datacenter named 'dc' would be created, and then a VM folder named "Terraform" would be created inside of that created datacenter.

Actual Behavior

Datacenter is created, but then the folder can't be created because the folder creation fails to find the correct datacenter object.

Steps to Reproduce

  1. set vc_user = login user for vCenter;
  2. set vc_password = password for vCenter user in step 1;
  3. set vc_fqdn = host / ip of the vCenter to connect to and operate on;
  4. terraform apply

Additional Notes

If I use terraform to create a folder in a pre-existing (manually created) Datacenter, it works as expected:

https://gist.github.com/kbpease/7815774f3cfaad443c14e7a7fed01b19

Note that the Datacenter ID is not "dc" now, but "datacenter-289".

@bill-rich bill-rich added the bug Type: Bug label Jul 5, 2018
@bill-rich
Copy link
Contributor

Hi @kbpease! I'd like to eventually get the id switched over to being the MOID instead of the name of the datacenter. To avoid breaking backwards compatibility, that will need to wait until v2.0 of the provider. In the meantime, I have added the moid attribute for the vsphere_datacenter resource in #575.

Using the following config for your folder in the 1.7.0 release:

resource "vsphere_folder" "terraform" {
  path = "Terraform"
  type = "vm"
  datacenter_id = "${vsphere_datacenter.dc.moid}"
}

@ghost ghost locked and limited conversation to collaborators Apr 18, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants