subnet = network.Subnet("server-subnet", resource_group_name=resource_group.name, virtual_network_name=net.name, address_prefix="10.0.2.0/24", enforce_private_link_endpoint_network_policies="false") public_ip = network.PublicIp("server-ip", resource_group_name=resource_group.name, location=resource_group.location, allocation_method="Dynamic") network_iface = network.NetworkInterface( "server-nic", resource_group_name=resource_group.name, location=resource_group.location, ip_configurations=[{ "name": "webserveripcfg", "subnet_id": subnet.id, "private_ip_address_allocation": "Dynamic", "public_ip_address_id": public_ip.id, }]) userdata = """#!/bin/bash echo "Hello, World!" > index.html nohup python -m SimpleHTTPServer 80 &""" vm = compute.VirtualMachine("server-vm", resource_group_name=resource_group.name, location=resource_group.location, network_interface_ids=[network_iface.id], vm_size="Standard_A0",
"version": "latest" } vm_config = [] vm_config.append({"name": "vm-dc", "img": img2019, "size": "Standard_B2ms"}) vm_config.append({"name": "vm-adc", "img": img2019, "size": "Standard_B2ms"}) vm_ids = [] for config in vm_config: nic = network.NetworkInterface(config["name"] + "nic", name=config["name"] + "nic", resource_group_name=rg.name, ip_configurations=[{ "name": "ipconfig1", "privateIpAddressAllocation": "Dynamic", "subnet_id": subnet.id }]) vm = compute.WindowsVirtualMachine( config["name"], opts=pulumi.ResourceOptions(depends_on=[nic]), resource_group_name=rg.name, location=rg.location, admin_username=server_user, admin_password=pwd, name=config["name"], network_interface_ids=[nic.id],
resource_group_name=resource_group.name, virtual_network_name=net.name, address_prefixes=["10.0.2.0/24"], enforce_private_link_endpoint_network_policies=False) public_ip = network.PublicIp("server-ip", resource_group_name=resource_group.name, location=resource_group.location, allocation_method="Dynamic") network_iface = network.NetworkInterface( "server-nic", resource_group_name=resource_group.name, location=resource_group.location, ip_configurations=[ network.NetworkInterfaceIpConfigurationArgs( name="webserveripcfg", subnet_id=subnet.id, private_ip_address_allocation="Dynamic", public_ip_address_id=public_ip.id, ) ]) userdata = """#!/bin/bash echo "Hello, World!" > index.html nohup python -m SimpleHTTPServer 80 &""" vm = compute.VirtualMachine( "server-vm", resource_group_name=resource_group.name, location=resource_group.location,
def __init__(self, name: str, args: WebServerArgs, opts: ResourceOptions = None): super().__init__("custom:app:WebServer", name, {}, opts) child_opts = ResourceOptions(parent=self) public_ip = network.PublicIp( "server-ip", resource_group_name=args.resource_group.name, location=args.resource_group.location, allocation_method="Dynamic", opts=child_opts, ) network_iface = network.NetworkInterface( "server-nic", resource_group_name=args.resource_group.name, location=args.resource_group.location, ip_configurations=[ network.NetworkInterfaceIpConfigurationArgs( name="webserveripcfg", subnet_id=args.subnet.id, private_ip_address_allocation="Dynamic", public_ip_address_id=public_ip.id, ) ], opts=child_opts, ) userdata = """#!/bin/bash echo "Hello, World!" > index.html nohup python -m SimpleHTTPServer 80 &""" vm = compute.VirtualMachine( "server-vm", resource_group_name=args.resource_group.name, location=args.resource_group.location, network_interface_ids=[network_iface.id], vm_size="Standard_A0", delete_data_disks_on_termination=True, delete_os_disk_on_termination=True, os_profile=compute.VirtualMachineOsProfileArgs( computer_name="hostname", admin_username=args.username, admin_password=args.password, custom_data=userdata, ), os_profile_linux_config=compute.VirtualMachineOsProfileLinuxConfigArgs( disable_password_authentication=False, ), storage_os_disk=compute.VirtualMachineStorageOsDiskArgs( create_option="FromImage", name="myosdisk1", ), storage_image_reference=compute.VirtualMachineStorageImageReferenceArgs( publisher="canonical", offer="UbuntuServer", sku="16.04-LTS", version="latest", ), opts=child_opts, ) # The public IP address is not allocated until the VM is running, so we wait # for that resource to create, and then lookup the IP address again to report # its public IP. combined_output = Output.all( vm.id, public_ip.name, public_ip.resource_group_name ) self.public_ip_addr = combined_output.apply( lambda lst: network.get_public_ip(name=lst[1], resource_group_name=lst[2]).ip_address ) self.register_outputs({})
source_uri=vhd_name_link, storage_account_name=storageaccount.name, storage_container_name=storagecontainer.name ) server_public_ip = network.PublicIp( "server-ip", resource_group_name=resource_group.name, location=resource_group.location, allocation_method="Dynamic") network_iface = network.NetworkInterface( "server-nic", resource_group_name=resource_group.name, ip_configurations=[{ "name": "registryVNIC", "subnet_id": subnet.id, "private_ip_address_allocation": "Dynamic", "public_ip_address_id": server_public_ip.id, }]) # create a Centos image - we will use it as registry mirror vm = compute.VirtualMachine( "server-vm", name="mirror", resource_group_name=resource_group.name, location=resource_group.location, network_interface_ids=[network_iface.id], vm_size="Standard_DS1_v2", delete_data_disks_on_termination=True, delete_os_disk_on_termination=True,
"name": "default", "address_prefix": "10.1.1.0/24", }]) subnet = network.Subnet("server-subnet", resource_group_name=resource_group.name, virtual_network_name=vnet.name, address_prefixes=['10.1.2.0/24'], name='pulumi-subnet') nic = network.NetworkInterface('nic', ip_configurations=[{ 'name': 'pulumi-ipconf', 'subnet_id': subnet.id, 'private_ip_address_allocation': 'Dynamic' }], location=resource_group.location, name='pulumi-nic', resource_group_name=resource_group.name) # Create instance instance = compute.VirtualMachine('machine', location=resource_group.location, name='pulumi-machine', network_interface_ids=[nic.id], os_profile={ "computer_name": "pulumi-machine", "admin_username": "******", "admin_password": password
resource_group = core.ResourceGroup(name) net = network.VirtualNetwork( name, resource_group_name=resource_group.name, address_spaces=["10.0.0.0/16"], subnets=[{ "name": "default", "address_prefix": "10.0.1.0/24", }]) network_interface = network.NetworkInterface( name, resource_group_name=resource_group.name, ip_configurations=[{ "name": "webserveripcfg", "subnet_id": net.subnets.apply(lambda subnets: subnets[0].get("id")), "private_ip_address_allocation": "dynamic", }]) vm = compute.VirtualMachine( "webservervm", resource_group_name=resource_group.name, network_interface_ids=[network_interface.id], vm_size="Standard_A0", delete_data_disks_on_termination=True, delete_os_disk_on_termination=True, os_profile={ "computer_name": "hostname", "admin_username": "******", "admin_password": "******",
# show off loop usage in pulumi names = ["vm1", "vm2", "vm3"] for name in names: # every vm needs its own public ip and interface public_ip = network.PublicIp( "{}-public-ip".format(name), resource_group_name=resource_group.name, location=resource_group.location, allocation_method="Dynamic") network_iface = network.NetworkInterface( "{}-nic".format(name), resource_group_name=resource_group.name, location=resource_group.location, ip_configurations=[{ "name": "server-ip", "subnet_id": subnet.id, "private_ip_address_allocation": "Dynamic", # just grab any ip "public_ip_address_id": public_ip.id, }]) # create vm itself vm = compute.VirtualMachine( "server-vm-{}".format(name), resource_group_name=resource_group.name, location=resource_group.location, network_interface_ids=[network_iface.id], vm_size="Standard_A0", # small vm delete_data_disks_on_termination=True, delete_os_disk_on_termination=True, os_profile={
) public_ip = network.PublicIp( 'server-ip', resource_group_name=resource_group.name, location=resource_group.location, public_ip_address_allocation='Dynamic', ) nic = network.NetworkInterface('server-nic', resource_group_name=resource_group.name, location=resource_group.location, ip_configurations=[{ 'name': 'ipconfig1', 'subnet_id': subnet.id, 'private_ip_address_allocation': 'Dynamic', 'public_ip_address_id': public_ip.id, }]) sa = storage.Account( 'diagnostics', resource_group_name=resource_group.name, location=resource_group.location, account_replication_type='LRS', account_tier='Standard', )
vms = [] vm_counter = 0 vm_size = 'Standard_B1ls' for virtual_machine in virtual_machines: ip_config = [{ "name": virtual_machine['name'], "subnet_id": subnet.id, "private_ip_address_allocation": "Dynamic"}] if 'public_ip' in virtual_machine and virtual_machine['public_ip'] == "true": ip_config[0]['public_ip_address_id'] = public_ip.id network_ifaces.append(network.NetworkInterface( virtual_machine['name'], name=virtual_machine['name'], resource_group_name=resource_group.name, location=resource_group.location, ip_configurations=ip_config) ) os_prof={ "computer_name": virtual_machine['name'], "admin_username": admin_username, } if 'custom_data' in virtual_machine and virtual_machine['custom_data'] == "true": os_prof['custom_data'] = userdata vms.append(compute.VirtualMachine( virtual_machine['name'], name=virtual_machine['name'], resource_group_name=resource_group.name,
net = network.VirtualNetwork(name, resource_group_name=resource_group.name, address_spaces=["10.0.0.0/16"], subnets=[ network.VirtualNetworkSubnetArgs( name="default", address_prefix="10.0.1.0/24", ) ]) network_interface = network.NetworkInterface( name, resource_group_name=resource_group.name, ip_configurations=[ network.NetworkInterfaceIpConfigurationArgs( name="webserveripcfg", subnet_id=net.subnets.apply(lambda subnets: subnets[0].id), private_ip_address_allocation="dynamic", ) ]) vm = compute.VirtualMachine( "webservervm", resource_group_name=resource_group.name, network_interface_ids=[network_interface.id], vm_size="Standard_A0", delete_data_disks_on_termination=True, delete_os_disk_on_termination=True, os_profile=compute.VirtualMachineOsProfileArgs( computer_name="hostname", admin_username="******",
storage_account_type = disks[d]['account_type'], disk_size_gb = disks[d]['size_gb'], zones = vm['availability_zone']) data_disks.append(dd) # Create Network Interface azsubnet = network.get_subnet( name=vnet['subnet_name'], virtual_network_name = vnet['name'], resource_group_name = vnet['resource_group_name']) aznic = network.NetworkInterface( 'nic', name = f"{vm['name']}-nic", resource_group_name = vm['resource_group_name'], ip_configurations = [{ "name": "ipconfig1", "private_ip_address_allocation": "Dynamic", "subnet_id": azsubnet.id}]) # Create VM osdiskname = f"{vm['name']}-osdisk" azvm = compute.VirtualMachine( 'vm', name = f"{vm['name']}", resource_group_name = vm['resource_group_name'], network_interface_ids = [aznic.id], vm_size = vm['size'], storage_os_disk = { "create_option": "FromImage", "name": osdiskname,