chilly-caravan-8120
04/09/2024, 1:54 PMget_public_ip_address()
function, it complains that the address doesn't exist yet. I'm sure it has something to do with how I've structured the build process. I have a dict array that holds what I want to build:chilly-caravan-8120
04/09/2024, 1:55 PMservers_to_build = [
{
"vm_name": "app",
"pip": True,
"os": "Windows",
},
{
"vm_name": "lin1",
"pip": False,
"os": "Ubuntu",
},
{
"vm_name": "lin2",
"pip": False,
"os": "Ubuntu",
},
]
for svr in servers_to_build:
nic = create_network_interface(
pulumi.get_stack() + "-" + svr["vm_name"], nsg, svr["pip"]
)
pulumi.export(svr["vm_name"], nic)
if svr["pip"]:
nic_pip_id = nic.ip_configurations[0].id
pulumi.export(
svr["vm_name"],
network.get_public_ip_address(
public_ip_address_name="pip-" + pulumi.get_stack() + "-" + svr["vm_name"],
resource_group_name=resource_group.name
),
)
vm = create_virtualmachine(
pulumi.get_stack() + "-" + svr["vm_name"], nic, svr["os"]
)
chilly-caravan-8120
04/09/2024, 1:56 PMcreate_network_interface()
function simply fills in the resource group and assigns the name of the interface. If svr["pip"]
is True
, then it creates the public IP address.adventurous-butcher-54166
04/09/2024, 3:59 PMadventurous-butcher-54166
04/09/2024, 4:06 PM