Terraform v0.12.6 default_ip_address

Hi All, I am using Terraform to provision some VMs using a vmware provider. I am having issues with converting my code to the newest terraform - which I need because I need to use the for_each functionality to assign VMs to their own specific vLan - which is based off the name of the vm itself. I am having issues with running custom scripts, which use ${element(vsphere_virtual_machine.tfvm.*.default_ip_address)}.This no longer works because terraform says that the attribute no longer exists. The issue is in the domain_join resource in the connection block, under host. I cannot grab that attribute with the newest version, even though I see it in the .tfstate file. Here is the code below. I need to pass all instances’ IP Address through that script to join it to the domain. Any help is very much appreciated.

provider “vsphere” {
version = “~> 1.10”
user = var.provider_account
password = var.provider_passwd
vsphere_server = var.vcenter
allow_unverified_ssl = true
}

provider “null” {
version = “~> 2.1”
}

=========================================================

VSPHERE, VCENTER RESOURCES REQUIRED FOR DEPLOYMENT

=========================================================

data “vsphere_datacenter” “datacenter” {
name = var.datacenter
}

data “vsphere_datastore” “datastore” {
name = var.datastore_name
datacenter_id = data.vsphere_datacenter.datacenter.id
}

data “vsphere_resource_pool” “pool” {
name = var.resource_pool
datacenter_id = data.vsphere_datacenter.datacenter.id
}

data “vsphere_network” “network” {
name = var.network_name
datacenter_id = data.vsphere_datacenter.datacenter.id
}

data “vsphere_network” “network1” {
count = var.VMcount
name = “{var.network_name1}-{format(”%02d", count.index + var.start_index)}"
datacenter_id = data.vsphere_datacenter.datacenter.id
}

data “vsphere_virtual_machine” “template” {
name = var.disk_template
datacenter_id = data.vsphere_datacenter.datacenter.id
}

=========================================================

FOLDER, TFVM RESOURCES ETC.

=========================================================

resource “vsphere_folder” “chefinfra” {
datacenter_id = data.vsphere_datacenter.datacenter.id
path = var.vmfolder
type = var.vsphere_folder_type
}

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

network_interface {
network_id = data.vsphere_network.network.id
adapter_type = “vmxnet3”
use_static_mac = var.static_mac
}

network_interface {
# each.key is the key from the map in for_each, which is
# the network id in this case
network_id = each.key
adapter_type = “vmxnet3”
use_static_mac = var.static_mac
}

disk {
label = “{var.vmname}{substr(each.value.name, -2, 2)}.vmdk”
size = data.vsphere_virtual_machine.template.disks[0].size
eagerly_scrub = data.vsphere_virtual_machine.template.disks[0].eagerly_scrub
thin_provisioned = data.vsphere_virtual_machine.template.disks[0].thin_provisioned
}

clone {
template_uuid = data.vsphere_virtual_machine.template.id
linked_clone = true
timeout = var.clone_timeout
customize {
timeout = var.customize_timeout

  windows_options {
    computer_name = "${var.vmname}${substr(each.value.name, -2, 2)}"
	time_zone     = var.timezone_win
  }
  
  network_interface{}
  network_interface{
	ipv4_address = "192.168.1.100"
	ipv4_netmask = 24
  }
  ipv4_gateway = "192.168.1.1"
  
}

}
}

=========================================================

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 -AdminPass > 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)}" type = "winrm" user = "{var.tmpl_account}”
password = “${var.tmpl_passwd}”
}
}