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

not able to access attributes on vsphere_virtual_machine #507

Closed
arewm opened this issue May 7, 2018 · 1 comment
Closed

not able to access attributes on vsphere_virtual_machine #507

arewm opened this issue May 7, 2018 · 1 comment

Comments

@arewm
Copy link

arewm commented May 7, 2018

When trying to access the attributes on VMs that I have created, Terraform is only reporting errors.

Terraform Version

$ terraform -v
Terraform v0.11.7
+ provider.random v1.2.0
+ provider.vsphere v1.4.1

vSphere Provider Version

$ terraform providers
.
└── module.my_module
    ├── provider.random
    └── provider.vsphere

Affected Resource(s)

I have only encountered the issue on, but I have not tried anything else

  • vsphere_virtual_machine
$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

random_pet.label: Refreshing state... (ID: sterling-doe)
vsphere_custom_attribute.requester: Refreshing state... (ID: 3826)
data.vsphere_datacenter.my_vsphere: Refreshing state...
vsphere_folder.vm_folder: Refreshing state... (ID: group-v25376)
data.vsphere_resource_pool.my_pool: Refreshing state...
data.vsphere_host.my_hosts[1]: Refreshing state...
data.vsphere_datastore.my_datastore: Refreshing state...
data.vsphere_network.my_public_network: Refreshing state...
data.vsphere_network.my_private_network: Refreshing state...
data.vsphere_virtual_machine.my_template: Refreshing state...
data.vsphere_host.my_hosts[0]: Refreshing state...
vsphere_virtual_machine.my_worker: Refreshing state... (ID: 4228e828-6f5a-3f5f-9d52-4e73e881e153)
vsphere_virtual_machine.my_master: Refreshing state... (ID: 4228864a-e5e7-a400-f61d-fc9bf65e3a05)

------------------------------------------------------------------------

Error: Error running plan: 1 error(s) occurred:

* module.my_module.output.workers: Resource 'vsphere_virtual_machine.my_worker' does not have attribute '*' for variable 'vsphere_virtual_machine.my_worker.*.*'

outputs.tf

output "workers" {
  value = ["${vsphere_virtual_machine.my_worker.*.*}"]
}

Other code that failed with similar behavior

I also tried to make a local-exec provisioner within the vsphere_virtual_machine resource, but

provisioner "local-exec" {
    command = "echo ${self.network_interface.*.ipv4_address}  ${self.name} >> ${path.cwd}/hosts"
}

also resulted in

Error: Error applying plan:

1 error(s) occurred:

* module.my_module.vsphere_virtual_machine.my_worker: Resource 'vsphere_virtual_machine.my_worker.0' does not have attribute 'network_interface.*.ipv4_address' for variable 'vsphere_virtual_machine.my_worker.0.network_interface.*.ipv4_address'

Expected Behavior

I was getting errors when trying to get the private ip address of my vm, so instead I tried to see all available attributes.

Actual Behavior

Terraform quit with an error when it should have given me all available attribuets

Important Factoids

I do not know if it matters, but I am using count to create potentially multiple VMs (but am currently only making one).

References

This might be related to:

@arewm
Copy link
Author

arewm commented May 8, 2018

I found the terraform.tfstate file to discover available attributes. I guess using *.* to determine the attributes is not supported.

The second problem that I reported was solved using the proper attribute since ipv4_address does not exist:

provisioner "local-exec" {
    command = "echo ${self.guest_ip_addresses.0}  ${self.name} >> ${path.cwd}/hosts"
}

Thanks for the patience @vancluever. Hopefully the documentation of this will help someone else. 😄

@arewm arewm closed this as completed May 8, 2018
@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
None yet
Projects
None yet
Development

No branches or pull requests

2 participants