This message was deleted.
# general
s
This message was deleted.
w
That should not happen if there is a true dependency between these resources. Is it possible you hardcoded in the name of the vnet instead of depending on the output of its name/or?
c
no, not hard-coded. Here is a snippet
Copy code
virtualNetwork, err := network.NewVirtualNetwork(ctx, vnetName, &network.VirtualNetworkArgs{
	Name:              vnetName,
	Location:          location,
	ResourceGroupName: resourceGroup.Name(),
	AddressSpaces:     VnetAddressSpaces,
})
if err != nil {
	return err
}

// Create hashicorp subnet
vaultSubnet, err := network.NewSubnet(ctx, HcSubnetName, &network.SubnetArgs{
	Name:               HcSubnetName,
	ResourceGroupName:  resourceGroup.Name(),
	VirtualNetworkName: virtualNetwork.Name(),
	AddressPrefix:      HcSubnetAddressSpaces,
})

// Create NICs for consul VMs
var consulcount [5]int
var consulNicobjects []interface{}
for i := range consulcount {
	consulnicename := fmt.Sprintf("consul-nic-%d", i)
	ipConfig := map[string]interface{}{
		"subnet_id":                     vaultSubnet.ID(),
		"name":                          fmt.Sprintf("consul-nic-ipc-%d", i),
		"private_ip_address_allocation": "Dynamic",
	}
	consulNic, err := network.NewNetworkInterface(ctx, consulnicename, &network.NetworkInterfaceArgs{
		Name:              consulnicename,
		ResourceGroupName: resourceGroup.Name(),
		Location:          location,
		IpConfigurations:  []interface{}{ipConfig},
	})
	if err != nil {
		return err
	}
	consulNicobjects := append(consulNicobjects, consulNic.ID())
	fmt.Println(consulNicobjects)
	ctx.Export("nic-name", consulNic.Name())
	ctx.Export("nic-Id", consulNic.ID())

}