Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Splat with for_each returns "this object does not have an attribute named ..." #22489

Closed
sanzen193 opened this issue Aug 16, 2019 · 6 comments
Closed
Labels
bug config v0.12 Issues (primarily bugs) reported against v0.12 releases

Comments

@sanzen193
Copy link

sanzen193 commented Aug 16, 2019

Terraform Version

v0.12.6

...

Terraform Configuration Files


resource "vsphere_virtual_machine" "tfvm" {
  for_each = {for net in data.vsphere_network.network1:net.id => net}

  datastore_id               = data.vsphere_datastore.datastore.id
  resource_pool_id           = data.vsphere_resource_pool.pool.id
  name                       = "${var.vmname}${substr(each.value.name, -2, 2)}"
  annotation                 = var.tfvm_annotation
  folder                     = vsphere_folder.chefinfra.path
  hv_mode                    = var.hv_mode
  nested_hv_enabled          = var.nested_hv_enabled
  num_cpus                   = var.cpu
  num_cores_per_socket       = var.cpu
  cpu_hot_add_enabled        = true
  cpu_hot_remove_enabled     = true
  memory                     = var.memory
  memory_hot_add_enabled     = true
  guest_id                   = var.guest_id
  scsi_type                  = data.vsphere_virtual_machine.template.scsi_type
  wait_for_guest_net_timeout = var.guest_net_timeout

      
    }
  }
}

# =========================================================
# ADDITIONAL RESOURCES FOR JOINING INTO DOMAIN,
# CONFIGURING AND PROVISIONING WITH CHEF
# =========================================================
# =========================================================

# Allow to add Windows VM to the domain
resource "null_resource" "domain_join" {
count = "${var.VMcount}"
  provisioner "file" {
    source = "./vmscripts/domain-add.ps1"
    destination = "c:/domain/domain-add.ps1"
    #destination = "c:/chef/domain-add.ps1"
  }

  provisioner "remote-exec" {
    inline = [
      "powershell.exe -ExecutionPolicy bypass -NoLogo -NonInteractive -File c:/domain/domain-add.ps1 -AdminAccount <generic_user> -AdminPass <generic_password>  > c:/domain/domain-add.ps1-log.log 2>&1"
    ]
  }
  
  provisioner "remote-exec" {
  inline = [
    "echo Scheduling reboot and stopping WinRM service so that next remote provisioner doesn't start during the shut down...",
    "shutdown /r /t 0 /c \"Joined domain\"",
    "net stop WinRM"
  ]
  on_failure = "continue"
  }

  
  connection {
   host = "${element(vsphere_virtual_machine.tfvm[*].default_ip_address, count.index + var.start_index)}"
   type = "winrm"
   user = var.tmpl_account
   password = var.tmpl_passwd
  }
}

Debug Output

Crash Output

Expected Behavior

What should have happened?
I removed some of my vsphere_virtual_machine configuration to reduce the amount of code in this post. Ultimately, I want all VMs to run my domain_join script.

Actual Behavior

What actually happened?
I receive an error stating that the default_IP_address attribute does not exist and therefore nothing gets passed

Steps to Reproduce

Please list the full steps required to reproduce the issue, for example:

  1. terraform init
  2. terraform apply

null_resource.domain_join[1]: Creating...

Error: Unsupported attribute: This object does not have an attribute named "default_ip_address".

Additional Context

Are there anything atypical about your situation that we should know? For example: is Terraform running in a wrapper script or in a CI system? Are you passing any unusual command line options or environment variables to opt-in to non-default behavior?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@sanzen193
Copy link
Author

Please let me know if I need to provide more information. Any help is appreciated. Thank you!

@ghost
Copy link

ghost commented Aug 16, 2019

This issue has been automatically migrated to hashicorp/terraform-provider-vsphere#823 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to hashicorp/terraform-provider-vsphere#823.

@ghost ghost closed this as completed Aug 16, 2019
@sanzen193
Copy link
Author

How did this issue get closed if it just points to the same exact issue that never got a response?

@teamterraform
Copy link
Contributor

teamterraform commented Aug 23, 2019

Hi @sanzen193,

Issues with providers are automatically moved to the correct repo where they can resolved, and closed in the Terraform repo.

On further inspection however, this isn't an issue with Azure specifically, and we can reopen it here for investigation.

@teamterraform teamterraform reopened this Aug 23, 2019
@teamterraform teamterraform changed the title Terraform default_IP_address v0.12.6 Splat with for_each returns "this object does not have an attribute named ..." Aug 23, 2019
@teamterraform teamterraform added the v0.12 Issues (primarily bugs) reported against v0.12 releases label Aug 23, 2019
@teamterraform
Copy link
Contributor

We have an issue open with a full description of the behavior already at #22562 .
Moving further discussion over there.

@ghost
Copy link

ghost commented Sep 23, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug config v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

No branches or pull requests

3 participants