import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Manages a virtual machine scale set. * * ## Example Usage * * ### With Managed Disks (Recommended) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * import * as std from "@pulumi/std"; * * const example = new azure.core.ResourceGroup("example", { * name: "example-resources", * location: "West Europe", * }); * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", { * name: "acctvn", * addressSpaces: ["10.0.0.0/16"], * location: example.location, * resourceGroupName: example.name, * }); * const exampleSubnet = new azure.network.Subnet("example", { * name: "acctsub", * resourceGroupName: example.name, * virtualNetworkName: exampleVirtualNetwork.name, * addressPrefixes: ["10.0.2.0/24"], * }); * const examplePublicIp = new azure.network.PublicIp("example", { * name: "test", * location: example.location, * resourceGroupName: example.name, * allocationMethod: "Static", * domainNameLabel: example.name, * tags: { * environment: "staging", * }, * }); * const exampleLoadBalancer = new azure.lb.LoadBalancer("example", { * name: "test", * location: example.location, * resourceGroupName: example.name, * frontendIpConfigurations: [{ * name: "PublicIPAddress", * publicIpAddressId: examplePublicIp.id, * }], * }); * const bpepool = new azure.lb.BackendAddressPool("bpepool", { * loadbalancerId: exampleLoadBalancer.id, * name: "BackEndAddressPool", * }); * const lbnatpool = new azure.lb.NatPool("lbnatpool", { * resourceGroupName: example.name, * name: "ssh", * loadbalancerId: exampleLoadBalancer.id, * protocol: "Tcp", * frontendPortStart: 50000, * frontendPortEnd: 50119, * backendPort: 22, * frontendIpConfigurationName: "PublicIPAddress", * }); * const exampleProbe = new azure.lb.Probe("example", { * loadbalancerId: exampleLoadBalancer.id, * name: "http-probe", * protocol: "Http", * requestPath: "/health", * port: 8080, * }); * const exampleScaleSet = new azure.compute.ScaleSet("example", { * name: "mytestscaleset-1", * location: example.location, * resourceGroupName: example.name, * automaticOsUpgrade: true, * upgradePolicyMode: "Rolling", * rollingUpgradePolicy: { * maxBatchInstancePercent: 20, * maxUnhealthyInstancePercent: 20, * maxUnhealthyUpgradedInstancePercent: 5, * pauseTimeBetweenBatches: "PT0S", * }, * healthProbeId: exampleProbe.id, * sku: { * name: "Standard_F2", * tier: "Standard", * capacity: 2, * }, * storageProfileImageReference: { * publisher: "Canonical", * offer: "0001-com-ubuntu-server-jammy", * sku: "22_04-lts", * version: "latest", * }, * storageProfileOsDisk: { * name: "", * caching: "ReadWrite", * createOption: "FromImage", * managedDiskType: "Standard_LRS", * }, * storageProfileDataDisks: [{ * lun: 0, * caching: "ReadWrite", * createOption: "Empty", * diskSizeGb: 10, * }], * osProfile: { * computerNamePrefix: "testvm", * adminUsername: "myadmin", * }, * osProfileLinuxConfig: { * disablePasswordAuthentication: true, * sshKeys: [{ * path: "/home/myadmin/.ssh/authorized_keys", * keyData: std.file({ * input: "~/.ssh/demo_key.pub", * }).then(invoke => invoke.result), * }], * }, * networkProfiles: [{ * name: "mynetworkprofile", * primary: true, * ipConfigurations: [{ * name: "TestIPConfiguration", * primary: true, * subnetId: exampleSubnet.id, * loadBalancerBackendAddressPoolIds: [bpepool.id], * loadBalancerInboundNatRulesIds: [lbnatpool.id], * }], * }], * tags: { * environment: "staging", * }, * }); * ``` * * ### With Unmanaged Disks * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * import * as std from "@pulumi/std"; * * const example = new azure.core.ResourceGroup("example", { * name: "example-resources", * location: "West Europe", * }); * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", { * name: "acctvn", * addressSpaces: ["10.0.0.0/16"], * location: example.location, * resourceGroupName: example.name, * }); * const exampleSubnet = new azure.network.Subnet("example", { * name: "acctsub", * resourceGroupName: example.name, * virtualNetworkName: exampleVirtualNetwork.name, * addressPrefixes: ["10.0.2.0/24"], * }); * const exampleAccount = new azure.storage.Account("example", { * name: "accsa", * resourceGroupName: example.name, * location: example.location, * accountTier: "Standard", * accountReplicationType: "LRS", * tags: { * environment: "staging", * }, * }); * const exampleContainer = new azure.storage.Container("example", { * name: "vhds", * storageAccountName: exampleAccount.name, * containerAccessType: "private", * }); * const exampleScaleSet = new azure.compute.ScaleSet("example", { * name: "mytestscaleset-1", * location: example.location, * resourceGroupName: example.name, * upgradePolicyMode: "Manual", * sku: { * name: "Standard_F2", * tier: "Standard", * capacity: 2, * }, * osProfile: { * computerNamePrefix: "testvm", * adminUsername: "myadmin", * }, * osProfileLinuxConfig: { * disablePasswordAuthentication: true, * sshKeys: [{ * path: "/home/myadmin/.ssh/authorized_keys", * keyData: std.file({ * input: "~/.ssh/demo_key.pub", * }).then(invoke => invoke.result), * }], * }, * networkProfiles: [{ * name: "TestNetworkProfile", * primary: true, * ipConfigurations: [{ * name: "TestIPConfiguration", * primary: true, * subnetId: exampleSubnet.id, * }], * }], * storageProfileOsDisk: { * name: "osDiskProfile", * caching: "ReadWrite", * createOption: "FromImage", * vhdContainers: [pulumi.interpolate`${exampleAccount.primaryBlobEndpoint}${exampleContainer.name}`], * }, * storageProfileImageReference: { * publisher: "Canonical", * offer: "0001-com-ubuntu-server-jammy", * sku: "22_04-lts", * version: "latest", * }, * }); * ``` * * ## Example of storageProfileImageReference with id * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * * const example = new azure.compute.Image("example", {name: "test"}); * const exampleScaleSet = new azure.compute.ScaleSet("example", { * name: "test", * storageProfileImageReference: { * id: example.id, * }, * }); * ``` * * ## API Providers * * * This resource uses the following Azure API Providers: * * * `Microsoft.Compute` - 2024-11-01 * * ## Import * * Virtual Machine Scale Sets can be imported using the `resource id`, e.g. * * ```sh * $ pulumi import azure:compute/scaleSet:ScaleSet scaleset1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleset1 * ``` */ export declare class ScaleSet extends pulumi.CustomResource { /** * Get an existing ScaleSet resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: ScaleSetState, opts?: pulumi.CustomResourceOptions): ScaleSet; /** * Returns true if the given object is an instance of ScaleSet. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is ScaleSet; /** * Automatic OS patches can be applied by Azure to your scaleset. This is particularly useful when `upgradePolicyMode` is set to `Rolling`. Defaults to `false`. */ readonly automaticOsUpgrade: pulumi.Output; /** * A `bootDiagnostics` block as referenced below. */ readonly bootDiagnostics: pulumi.Output; /** * Specifies the eviction policy for Virtual Machines in this Scale Set. Possible values are `Deallocate` and `Delete`. Changing this forces a new resource to be created. * * > **NOTE:** `evictionPolicy` can only be set when `priority` is set to `Low`. */ readonly evictionPolicy: pulumi.Output; /** * Can be specified multiple times to add extension profiles to the scale set. Each `extension` block supports the fields documented below. */ readonly extensions: pulumi.Output; /** * Specifies the identifier for the load balancer health probe. Required when using `Rolling` as your `upgradePolicyMode`. */ readonly healthProbeId: pulumi.Output; /** * An `identity` block as defined below. */ readonly identity: pulumi.Output; /** * (Optional, when a Windows machine) Specifies the Windows OS license type. If supplied, the only allowed values are `Windows_Client` and `Windows_Server`. */ readonly licenseType: pulumi.Output; /** * Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. */ readonly location: pulumi.Output; /** * Specifies the name of the virtual machine scale set resource. Changing this forces a new resource to be created. */ readonly name: pulumi.Output; /** * A collection of `networkProfile` blocks as documented below. */ readonly networkProfiles: pulumi.Output; /** * A `osProfile` block as documented below. */ readonly osProfile: pulumi.Output; /** * A `osProfileLinuxConfig` block as documented below. */ readonly osProfileLinuxConfig: pulumi.Output; /** * A collection of `osProfileSecrets` blocks as documented below. */ readonly osProfileSecrets: pulumi.Output; /** * A `osProfileWindowsConfig` block as documented below. */ readonly osProfileWindowsConfig: pulumi.Output; /** * Specifies whether the virtual machine scale set should be overprovisioned. Defaults to `true`. */ readonly overprovision: pulumi.Output; /** * A `plan` block as documented below. */ readonly plan: pulumi.Output; /** * Specifies the priority for the Virtual Machines in the Scale Set. Possible values are `Low` and `Regular`. Changing this forces a new resource to be created. */ readonly priority: pulumi.Output; /** * The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. Changing this forces a new resource to be created */ readonly proximityPlacementGroupId: pulumi.Output; /** * The name of the resource group in which to create the virtual machine scale set. Changing this forces a new resource to be created. */ readonly resourceGroupName: pulumi.Output; /** * A `rollingUpgradePolicy` block as defined below. This is only applicable when the `upgradePolicyMode` is `Rolling`. */ readonly rollingUpgradePolicy: pulumi.Output; /** * Specifies whether the scale set is limited to a single placement group with a maximum size of 100 virtual machines. If set to false, managed disks must be used. Changing this forces a new resource to be created. See [documentation](https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-placement-groups) for more information. Defaults to `true`. */ readonly singlePlacementGroup: pulumi.Output; /** * A `sku` block as documented below. */ readonly sku: pulumi.Output; /** * A `storageProfileDataDisk` block as documented below. */ readonly storageProfileDataDisks: pulumi.Output; /** * A `storageProfileImageReference` block as documented below. */ readonly storageProfileImageReference: pulumi.Output; /** * A `storageProfileOsDisk` block as documented below. */ readonly storageProfileOsDisk: pulumi.Output; /** * A mapping of tags to assign to the resource. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Specifies the mode of an upgrade to virtual machines in the scale set. Possible values, `Rolling`, `Manual`, or `Automatic`. When choosing `Rolling`, you will need to set a health probe. */ readonly upgradePolicyMode: pulumi.Output; /** * A collection of availability zones to spread the Virtual Machines over. Changing this forces a new resource to be created. * * > **NOTE:** Availability Zones are [only supported in several regions at this time](https://docs.microsoft.com/azure/availability-zones/az-overview). */ readonly zones: pulumi.Output; /** * Create a ScaleSet resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: ScaleSetArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering ScaleSet resources. */ export interface ScaleSetState { /** * Automatic OS patches can be applied by Azure to your scaleset. This is particularly useful when `upgradePolicyMode` is set to `Rolling`. Defaults to `false`. */ automaticOsUpgrade?: pulumi.Input; /** * A `bootDiagnostics` block as referenced below. */ bootDiagnostics?: pulumi.Input; /** * Specifies the eviction policy for Virtual Machines in this Scale Set. Possible values are `Deallocate` and `Delete`. Changing this forces a new resource to be created. * * > **NOTE:** `evictionPolicy` can only be set when `priority` is set to `Low`. */ evictionPolicy?: pulumi.Input; /** * Can be specified multiple times to add extension profiles to the scale set. Each `extension` block supports the fields documented below. */ extensions?: pulumi.Input[]>; /** * Specifies the identifier for the load balancer health probe. Required when using `Rolling` as your `upgradePolicyMode`. */ healthProbeId?: pulumi.Input; /** * An `identity` block as defined below. */ identity?: pulumi.Input; /** * (Optional, when a Windows machine) Specifies the Windows OS license type. If supplied, the only allowed values are `Windows_Client` and `Windows_Server`. */ licenseType?: pulumi.Input; /** * Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. */ location?: pulumi.Input; /** * Specifies the name of the virtual machine scale set resource. Changing this forces a new resource to be created. */ name?: pulumi.Input; /** * A collection of `networkProfile` blocks as documented below. */ networkProfiles?: pulumi.Input[]>; /** * A `osProfile` block as documented below. */ osProfile?: pulumi.Input; /** * A `osProfileLinuxConfig` block as documented below. */ osProfileLinuxConfig?: pulumi.Input; /** * A collection of `osProfileSecrets` blocks as documented below. */ osProfileSecrets?: pulumi.Input[]>; /** * A `osProfileWindowsConfig` block as documented below. */ osProfileWindowsConfig?: pulumi.Input; /** * Specifies whether the virtual machine scale set should be overprovisioned. Defaults to `true`. */ overprovision?: pulumi.Input; /** * A `plan` block as documented below. */ plan?: pulumi.Input; /** * Specifies the priority for the Virtual Machines in the Scale Set. Possible values are `Low` and `Regular`. Changing this forces a new resource to be created. */ priority?: pulumi.Input; /** * The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. Changing this forces a new resource to be created */ proximityPlacementGroupId?: pulumi.Input; /** * The name of the resource group in which to create the virtual machine scale set. Changing this forces a new resource to be created. */ resourceGroupName?: pulumi.Input; /** * A `rollingUpgradePolicy` block as defined below. This is only applicable when the `upgradePolicyMode` is `Rolling`. */ rollingUpgradePolicy?: pulumi.Input; /** * Specifies whether the scale set is limited to a single placement group with a maximum size of 100 virtual machines. If set to false, managed disks must be used. Changing this forces a new resource to be created. See [documentation](https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-placement-groups) for more information. Defaults to `true`. */ singlePlacementGroup?: pulumi.Input; /** * A `sku` block as documented below. */ sku?: pulumi.Input; /** * A `storageProfileDataDisk` block as documented below. */ storageProfileDataDisks?: pulumi.Input[]>; /** * A `storageProfileImageReference` block as documented below. */ storageProfileImageReference?: pulumi.Input; /** * A `storageProfileOsDisk` block as documented below. */ storageProfileOsDisk?: pulumi.Input; /** * A mapping of tags to assign to the resource. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Specifies the mode of an upgrade to virtual machines in the scale set. Possible values, `Rolling`, `Manual`, or `Automatic`. When choosing `Rolling`, you will need to set a health probe. */ upgradePolicyMode?: pulumi.Input; /** * A collection of availability zones to spread the Virtual Machines over. Changing this forces a new resource to be created. * * > **NOTE:** Availability Zones are [only supported in several regions at this time](https://docs.microsoft.com/azure/availability-zones/az-overview). */ zones?: pulumi.Input[]>; } /** * The set of arguments for constructing a ScaleSet resource. */ export interface ScaleSetArgs { /** * Automatic OS patches can be applied by Azure to your scaleset. This is particularly useful when `upgradePolicyMode` is set to `Rolling`. Defaults to `false`. */ automaticOsUpgrade?: pulumi.Input; /** * A `bootDiagnostics` block as referenced below. */ bootDiagnostics?: pulumi.Input; /** * Specifies the eviction policy for Virtual Machines in this Scale Set. Possible values are `Deallocate` and `Delete`. Changing this forces a new resource to be created. * * > **NOTE:** `evictionPolicy` can only be set when `priority` is set to `Low`. */ evictionPolicy?: pulumi.Input; /** * Can be specified multiple times to add extension profiles to the scale set. Each `extension` block supports the fields documented below. */ extensions?: pulumi.Input[]>; /** * Specifies the identifier for the load balancer health probe. Required when using `Rolling` as your `upgradePolicyMode`. */ healthProbeId?: pulumi.Input; /** * An `identity` block as defined below. */ identity?: pulumi.Input; /** * (Optional, when a Windows machine) Specifies the Windows OS license type. If supplied, the only allowed values are `Windows_Client` and `Windows_Server`. */ licenseType?: pulumi.Input; /** * Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. */ location?: pulumi.Input; /** * Specifies the name of the virtual machine scale set resource. Changing this forces a new resource to be created. */ name?: pulumi.Input; /** * A collection of `networkProfile` blocks as documented below. */ networkProfiles: pulumi.Input[]>; /** * A `osProfile` block as documented below. */ osProfile: pulumi.Input; /** * A `osProfileLinuxConfig` block as documented below. */ osProfileLinuxConfig?: pulumi.Input; /** * A collection of `osProfileSecrets` blocks as documented below. */ osProfileSecrets?: pulumi.Input[]>; /** * A `osProfileWindowsConfig` block as documented below. */ osProfileWindowsConfig?: pulumi.Input; /** * Specifies whether the virtual machine scale set should be overprovisioned. Defaults to `true`. */ overprovision?: pulumi.Input; /** * A `plan` block as documented below. */ plan?: pulumi.Input; /** * Specifies the priority for the Virtual Machines in the Scale Set. Possible values are `Low` and `Regular`. Changing this forces a new resource to be created. */ priority?: pulumi.Input; /** * The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. Changing this forces a new resource to be created */ proximityPlacementGroupId?: pulumi.Input; /** * The name of the resource group in which to create the virtual machine scale set. Changing this forces a new resource to be created. */ resourceGroupName: pulumi.Input; /** * A `rollingUpgradePolicy` block as defined below. This is only applicable when the `upgradePolicyMode` is `Rolling`. */ rollingUpgradePolicy?: pulumi.Input; /** * Specifies whether the scale set is limited to a single placement group with a maximum size of 100 virtual machines. If set to false, managed disks must be used. Changing this forces a new resource to be created. See [documentation](https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-placement-groups) for more information. Defaults to `true`. */ singlePlacementGroup?: pulumi.Input; /** * A `sku` block as documented below. */ sku: pulumi.Input; /** * A `storageProfileDataDisk` block as documented below. */ storageProfileDataDisks?: pulumi.Input[]>; /** * A `storageProfileImageReference` block as documented below. */ storageProfileImageReference?: pulumi.Input; /** * A `storageProfileOsDisk` block as documented below. */ storageProfileOsDisk: pulumi.Input; /** * A mapping of tags to assign to the resource. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Specifies the mode of an upgrade to virtual machines in the scale set. Possible values, `Rolling`, `Manual`, or `Automatic`. When choosing `Rolling`, you will need to set a health probe. */ upgradePolicyMode: pulumi.Input; /** * A collection of availability zones to spread the Virtual Machines over. Changing this forces a new resource to be created. * * > **NOTE:** Availability Zones are [only supported in several regions at this time](https://docs.microsoft.com/azure/availability-zones/az-overview). */ zones?: pulumi.Input[]>; }