subcategory | layout | page_title | description |
---|---|---|---|
Compute |
azurerm |
Azure Resource Manager: azurerm_windows_virtual_machine_scale_set |
Manages a Windows Virtual Machine Scale Set. |
Manages a Windows Virtual Machine Scale Set.
-> Note: As of the v2.86.0 (November 19, 2021) release of the provider this resource will only create Virtual Machine Scale Sets with the Uniform Orchestration Mode. For Virtual Machine Scale Sets with Flexible orchestration mode, use azurerm_orchestrated_virtual_machine_scale_set
. Flexible orchestration mode is recommended for workloads on Azure.
-> Note: All arguments including the administrator login and password will be stored in the raw state as plain-text. Read more about sensitive data in state.
-> Note: Terraform will automatically update & reimage the nodes in the Scale Set (if Required) during an Update - this behaviour can be configured using the features
setting within the Provider block.
-> Note: This resource does not support Unmanaged Disks. If you need to use Unmanaged Disks you can continue to use the azurerm_virtual_machine_scale_set
resource instead
This example provisions a basic Windows Virtual Machine Scale Set on an internal network. Additional examples of how to use the azurerm_windows_virtual_machine_scale_set
resource can be found in the ./examples/vm-scale-set/windows` directory within the Github Repository.
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_virtual_network" "example" {
name = "example-network"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
address_space = ["10.0.0.0/16"]
}
resource "azurerm_subnet" "internal" {
name = "internal"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.2.0/24"]
}
resource "azurerm_windows_virtual_machine_scale_set" "example" {
name = "example-vmss"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
sku = "Standard_F2"
instances = 1
admin_password = "P@55w0rd1234!"
admin_username = "adminuser"
computer_name_prefix = "vm-"
source_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = "2016-Datacenter-Server-Core"
version = "latest"
}
os_disk {
storage_account_type = "Standard_LRS"
caching = "ReadWrite"
}
network_interface {
name = "example"
primary = true
ip_configuration {
name = "internal"
primary = true
subnet_id = azurerm_subnet.internal.id
}
}
}
-
name
- (Required) The name of the Windows Virtual Machine Scale Set. Changing this forces a new resource to be created. -
location
- (Required) The Azure location where the Windows Virtual Machine Scale Set should exist. Changing this forces a new resource to be created. -
resource_group_name
- (Required) The name of the Resource Group in which the Windows Virtual Machine Scale Set should be exist. Changing this forces a new resource to be created. -
admin_password
- (Required) The Password which should be used for the local-administrator on this Virtual Machine. Changing this forces a new resource to be created. -
admin_username
- (Required) The username of the local administrator on each Virtual Machine Scale Set instance. Changing this forces a new resource to be created. -
instances
- (Required) The number of Virtual Machines in the Scale Set.
-> Note: If you're using AutoScaling, you may wish to use Terraform's ignore_changes
functionality to ignore changes to this field.
-
sku
- (Required) The Virtual Machine SKU for the Scale Set, such asStandard_F2
. -
network_interface
- (Required) One or morenetwork_interface
blocks as defined below. -
os_disk
- (Required) Anos_disk
block as defined below.
-
additional_capabilities
- (Optional) Anadditional_capabilities
block as defined below. -
additional_unattend_content
- (Optional) One or moreadditional_unattend_content
blocks as defined below. Changing this forces a new resource to be created. -
automatic_os_upgrade_policy
- (Optional) Anautomatic_os_upgrade_policy
block as defined below. This can only be specified whenupgrade_mode
is set to eitherAutomatic
orRolling
. -
automatic_instance_repair
- (Optional) Anautomatic_instance_repair
block as defined below. To enable the automatic instance repair, this Virtual Machine Scale Set must have a validhealth_probe_id
or an Application Health Extension.
-> Note: For more information about Automatic Instance Repair, please refer to this doc.
-
boot_diagnostics
- (Optional) Aboot_diagnostics
block as defined below. -
capacity_reservation_group_id
- (Optional) Specifies the ID of the Capacity Reservation Group which the Virtual Machine Scale Set should be allocated to. Changing this forces a new resource to be created.
~> Note: capacity_reservation_group_id
cannot be used with proximity_placement_group_id
~> Note: single_placement_group
must be set to false
when capacity_reservation_group_id
is specified.
-
computer_name_prefix
- (Optional) The prefix which should be used for the name of the Virtual Machines in this Scale Set. If unspecified this defaults to the value for thename
field. If the value of thename
field is not a validcomputer_name_prefix
, then you must specifycomputer_name_prefix
. Changing this forces a new resource to be created. -
custom_data
- (Optional) The Base64-Encoded Custom Data which should be used for this Virtual Machine Scale Set.
-> Note: When Custom Data has been configured, it's not possible to remove it without tainting the Virtual Machine Scale Set, due to a limitation of the Azure API.
-
data_disk
- (Optional) One or moredata_disk
blocks as defined below. -
do_not_run_extensions_on_overprovisioned_machines
- (Optional) Should Virtual Machine Extensions be run on Overprovisioned Virtual Machines in the Scale Set? Defaults tofalse
. -
edge_zone
- (Optional) Specifies the Edge Zone within the Azure Region where this Windows Virtual Machine Scale Set should exist. Changing this forces a new Windows Virtual Machine Scale Set to be created. -
enable_automatic_updates
- (Optional) Are automatic updates enabled for this Virtual Machine? Defaults totrue
. -
encryption_at_host_enabled
- (Optional) Should all of the disks (including the temp disk) attached to this Virtual Machine be encrypted by enabling Encryption at Host? -
extension
- (Optional) One or moreextension
blocks as defined below -
extension_operations_enabled
- (Optional) Should extension operations be allowed on the Virtual Machine Scale Set? Possible values aretrue
orfalse
. Defaults totrue
. Changing this forces a new Windows Virtual Machine Scale Set to be created.
-> Note: extension_operations_enabled
may only be set to false
if there are no extensions defined in the extension
field.
-
extensions_time_budget
- (Optional) Specifies the duration allocated for all extensions to start. The time duration should be between15
minutes and120
minutes (inclusive) and should be specified in ISO 8601 format. Defaults toPT1H30M
. -
eviction_policy
- (Optional) Specifies the eviction policy for Virtual Machines in this Scale Set. Possible values areDeallocate
andDelete
. Changing this forces a new resource to be created.
-> Note: This can only be configured when priority
is set to Spot
.
-
gallery_application
- (Optional) One or moregallery_application
blocks as defined below. -
health_probe_id
- (Optional) The ID of a Load Balancer Probe which should be used to determine the health of an instance. This is Required and can only be specified whenupgrade_mode
is set toAutomatic
orRolling
. -
host_group_id
- (Optional) Specifies the ID of the dedicated host group that the virtual machine scale set resides in. Changing this forces a new resource to be created. -
identity
- (Optional) Anidentity
block as defined below. -
license_type
- (Optional) Specifies the type of on-premise license (also known as Azure Hybrid Use Benefit) which should be used for this Virtual Machine Scale Set. Possible values areNone
,Windows_Client
andWindows_Server
. -
max_bid_price
- (Optional) The maximum price you're willing to pay for each Virtual Machine in this Scale Set, in US Dollars; which must be greater than the current spot price. If this bid price falls below the current spot price the Virtual Machines in the Scale Set will be evicted using theeviction_policy
. Defaults to-1
, which means that each Virtual Machine in the Scale Set should not be evicted for price reasons.
-> Note: This can only be configured when priority
is set to Spot
.
-
overprovision
- (Optional) Should Azure over-provision Virtual Machines in this Scale Set? This means that multiple Virtual Machines will be provisioned and Azure will keep the instances which become available first - which improves provisioning success rates and improves deployment time. You're not billed for these over-provisioned VM's and they don't count towards the Subscription Quota. Defaults totrue
. -
plan
- (Optional) Aplan
block as defined below. Changing this forces a new resource to be created.
-> Note: When using an image from Azure Marketplace a plan
must be specified.
-
platform_fault_domain_count
- (Optional) Specifies the number of fault domains that are used by this Linux Virtual Machine Scale Set. Changing this forces a new resource to be created. -
priority
- (Optional) The Priority of this Virtual Machine Scale Set. Possible values areRegular
andSpot
. Defaults toRegular
. Changing this value forces a new resource.
-> Note: When priority
is set to Spot
an eviction_policy
must be specified.
-
provision_vm_agent
- (Optional) Should the Azure VM Agent be provisioned on each Virtual Machine in the Scale Set? Defaults totrue
. Changing this value forces a new resource to be created. -
proximity_placement_group_id
- (Optional) The ID of the Proximity Placement Group in which the Virtual Machine Scale Set should be assigned to. Changing this forces a new resource to be created. -
rolling_upgrade_policy
- (Optional) Arolling_upgrade_policy
block as defined below. This is Required and can only be specified whenupgrade_mode
is set toAutomatic
orRolling
. Changing this forces a new resource to be created. -
scale_in
- (Optional) Ascale_in
block as defined below. -
secret
- (Optional) One or moresecret
blocks as defined below. -
secure_boot_enabled
- (Optional) Specifies if Secure Boot and Trusted Launch is enabled for the Virtual Machine. Changing this forces a new resource to be created. -
single_placement_group
- (Optional) Should this Virtual Machine Scale Set be limited to a Single Placement Group, which means the number of instances will be capped at 100 Virtual Machines. Defaults totrue
. -
source_image_id
- (Optional) The ID of an Image which each Virtual Machine in this Scale Set should be based on. Possible Image ID types includeImage ID
,Shared Image ID
,Shared Image Version ID
,Community Gallery Image ID
,Community Gallery Image Version ID
,Shared Gallery Image ID
andShared Gallery Image Version ID
.
-> Note: One of either source_image_id
or source_image_reference
must be set.
source_image_reference
- (Optional) Asource_image_reference
block as defined below.
-> Note: One of either source_image_id
or source_image_reference
must be set.
-
spot_restore
- (Optional) Aspot_restore
block as defined below. -
tags
- (Optional) A mapping of tags which should be assigned to this Virtual Machine Scale Set. -
termination_notification
- (Optional) Atermination_notification
block as defined below. -
timezone
- (Optional) Specifies the time zone of the virtual machine, the possible values are defined here. -
upgrade_mode
- (Optional) Specifies how Upgrades (e.g. changing the Image/SKU) should be performed to Virtual Machine Instances. Possible values areAutomatic
,Manual
andRolling
. Defaults toManual
. Changing this forces a new resource to be created.
-> Note: If rolling upgrades are configured and running on a Linux Virtual Machine Scale Set, they will be cancelled when Terraform tries to destroy the resource.
-
user_data
- (Optional) The Base64-Encoded User Data which should be used for this Virtual Machine Scale Set. -
vtpm_enabled
- (Optional) Specifies if vTPM (Virtual Trusted Platform Module) and Trusted Launch is enabled for the Virtual Machine. Changing this forces a new resource to be created. -
winrm_listener
- (Optional) One or morewinrm_listener
blocks as defined below. Changing this forces a new resource to be created. -
zone_balance
- (Optional) Should the Virtual Machines in this Scale Set be strictly evenly distributed across Availability Zones? Defaults tofalse
. Changing this forces a new resource to be created.
-> Note: This can only be set to true
when one or more zones
are configured.
zones
- (Optional) Specifies a list of Availability Zones in which this Windows Virtual Machine Scale Set should be located.
-> Note: Updating zones
to remove an existing zone forces a new Virtual Machine Scale Set to be created.
An additional_capabilities
block supports the following:
ultra_ssd_enabled
- (Optional) Should the capacity to enable Data Disks of theUltraSSD_LRS
storage account type be supported on this Virtual Machine Scale Set? Possible values aretrue
orfalse
. Defaults tofalse
. Changing this forces a new resource to be created.
An additional_unattend_content
block supports the following:
-
content
- (Required) The XML formatted content that is added to the unattend.xml file for the specified path and component. Changing this forces a new resource to be created. -
setting
- (Required) The name of the setting to which the content applies. Possible values areAutoLogon
andFirstLogonCommands
. Changing this forces a new resource to be created.
An automatic_os_upgrade_policy
block supports the following:
-
disable_automatic_rollback
- (Required) Should automatic rollbacks be disabled? -
enable_automatic_os_upgrade
- (Required) Should OS Upgrades automatically be applied to Scale Set instances in a rolling fashion when a newer version of the OS Image becomes available?
An automatic_instance_repair
block supports the following:
-
enabled
- (Required) Should the automatic instance repair be enabled on this Virtual Machine Scale Set? -
grace_period
- (Optional) Amount of time for which automatic repairs will be delayed. The grace period starts right after the VM is found unhealthy. Possible values are between10
and90
minutes. The time duration should be specified inISO 8601
format (e.g.PT10M
toPT90M
).
-> Note: Once the grace_period
field has been set it will always return the last value it was assigned if it is removed from the configuration file.
action
- (Optional) The repair action that will be used for repairing unhealthy virtual machines in the scale set. Possible values includeReplace
,Restart
,Reimage
.
-> Note: Once the action
field has been set it will always return the last value it was assigned if it is removed from the configuration file.
-> Note: If you wish to update the repair action
of an existing automatic_instance_repair
policy, you must first disable
the automatic_instance_repair
policy before you can re-enable the automatic_instance_repair
policy with the new repair action
defined.
A boot_diagnostics
block supports the following:
storage_account_uri
- (Optional) The Primary/Secondary Endpoint for the Azure Storage Account which should be used to store Boot Diagnostics, including Console Output and Screenshots from the Hypervisor.
-> Note: Passing a null value will utilize a Managed Storage Account to store Boot Diagnostics
A certificate
block supports the following:
-
store
- (Required) The certificate store on the Virtual Machine where the certificate should be added. -
url
- (Required) The Secret URL of a Key Vault Certificate.
-> Note: This can be sourced from the secret_id
field within the azurerm_key_vault_certificate
Resource.
A data_disk
block supports the following:
-
name
- (Optional) The name of the Data Disk. -
caching
- (Required) The type of Caching which should be used for this Data Disk. Possible values areNone
,ReadOnly
andReadWrite
. -
create_option
- (Optional) The create option which should be used for this Data Disk. Possible values areEmpty
andFromImage
. Defaults toEmpty
. (FromImage
should only be used if the source image includes data disks). -
disk_size_gb
- (Required) The size of the Data Disk which should be created. -
lun
- (Required) The Logical Unit Number of the Data Disk, which must be unique within the Virtual Machine. -
storage_account_type
- (Required) The Type of Storage Account which should back this Data Disk. Possible values includeStandard_LRS
,StandardSSD_LRS
,StandardSSD_ZRS
,Premium_LRS
,PremiumV2_LRS
,Premium_ZRS
andUltraSSD_LRS
.
-> Note: UltraSSD_LRS
is only supported when ultra_ssd_enabled
within the additional_capabilities
block is enabled.
disk_encryption_set_id
- (Optional) The ID of the Disk Encryption Set which should be used to encrypt this Data Disk. Changing this forces a new resource to be created.
-> Note: The Disk Encryption Set must have the Reader
Role Assignment scoped on the Key Vault - in addition to an Access Policy to the Key Vault
-> Note: Disk Encryption Sets are in Public Preview in a limited set of regions
-
ultra_ssd_disk_iops_read_write
- (Optional) Specifies the Read-Write IOPS for this Data Disk. Only settable whenstorage_account_type
isPremiumV2_LRS
orUltraSSD_LRS
. -
ultra_ssd_disk_mbps_read_write
- (Optional) Specifies the bandwidth in MB per second for this Data Disk. Only settable whenstorage_account_type
isPremiumV2_LRS
orUltraSSD_LRS
. -
write_accelerator_enabled
- (Optional) Should Write Accelerator be enabled for this Data Disk? Defaults tofalse
.
-> Note: This requires that the storage_account_type
is set to Premium_LRS
and that caching
is set to None
.
A diff_disk_settings
block supports the following:
-
option
- (Required) Specifies the Ephemeral Disk Settings for the OS Disk. At this time the only possible value isLocal
. Changing this forces a new resource to be created. -
placement
- (Optional) Specifies where to store the Ephemeral Disk. Possible values areCacheDisk
andResourceDisk
. Defaults toCacheDisk
. Changing this forces a new resource to be created.
An extension
block supports the following:
-
name
- (Required) The name for the Virtual Machine Scale Set Extension. -
publisher
- (Required) Specifies the Publisher of the Extension. -
type
- (Required) Specifies the Type of the Extension. -
type_handler_version
- (Required) Specifies the version of the extension to use, available versions can be found using the Azure CLI. -
auto_upgrade_minor_version
- (Optional) Should the latest version of the Extension be used at Deployment Time, if one is available? This won't auto-update the extension on existing installation. Defaults totrue
. -
automatic_upgrade_enabled
- (Optional) Should the Extension be automatically updated whenever the Publisher releases a new version of this VM Extension? -
force_update_tag
- (Optional) A value which, when different to the previous value can be used to force-run the Extension even if the Extension Configuration hasn't changed. -
protected_settings
- (Optional) A JSON String which specifies Sensitive Settings (such as Passwords) for the Extension.
-> Note: Keys within the protected_settings
block are notoriously case-sensitive, where the casing required (e.g. TitleCase vs snakeCase) depends on the Extension being used. Please refer to the documentation for the specific Virtual Machine Extension you're looking to use for more information.
-> Note: Rather than defining JSON inline you can use the jsonencode
interpolation function to define this in a cleaner way.
protected_settings_from_key_vault
- (Optional) Aprotected_settings_from_key_vault
block as defined below.
~> Note: protected_settings_from_key_vault
cannot be used with protected_settings
-
provision_after_extensions
- (Optional) An ordered list of Extension names which this should be provisioned after. -
settings
- (Optional) A JSON String which specifies Settings for the Extension.
-> Note: Keys within the settings
block are notoriously case-sensitive, where the casing required (e.g. TitleCase vs snakeCase) depends on the Extension being used. Please refer to the documentation for the specific Virtual Machine Extension you're looking to use for more information.
-> Note: Rather than defining JSON inline you can use the jsonencode
interpolation function to define this in a cleaner way.
A gallery_application
block supports the following:
-
version_id
- (Required) Specifies the Gallery Application Version resource ID. Changing this forces a new resource to be created. -
configuration_blob_uri
- (Optional) Specifies the URI to an Azure Blob that will replace the default configuration for the package if provided. Changing this forces a new resource to be created. -
order
- (Optional) Specifies the order in which the packages have to be installed. Possible values are between0
and2147483647
. Defaults to0
. Changing this forces a new resource to be created. -
tag
- (Optional) Specifies a passthrough value for more generic context. This field can be any validstring
value. Changing this forces a new resource to be created.
An identity
block supports the following:
-
type
- (Required) Specifies the type of Managed Service Identity that should be configured on this Windows Virtual Machine Scale Set. Possible values areSystemAssigned
,UserAssigned
,SystemAssigned, UserAssigned
(to enable both). -
identity_ids
- (Optional) Specifies a list of User Assigned Managed Identity IDs to be assigned to this Windows Virtual Machine Scale Set.
-> Note: This is required when type
is set to UserAssigned
or SystemAssigned, UserAssigned
.
An ip_configuration
block supports the following:
-
name
- (Required) The Name which should be used for this IP Configuration. -
application_gateway_backend_address_pool_ids
- (Optional) A list of Backend Address Pools ID's from a Application Gateway which this Virtual Machine Scale Set should be connected to. -
application_security_group_ids
- (Optional) A list of Application Security Group ID's which this Virtual Machine Scale Set should be connected to. -
load_balancer_backend_address_pool_ids
- (Optional) A list of Backend Address Pools ID's from a Load Balancer which this Virtual Machine Scale Set should be connected to.
-> Note: When the Virtual Machine Scale Set is configured to have public IPs per instance are created with a load balancer, the SKU of the Virtual Machine instance IPs is determined by the SKU of the Virtual Machine Scale Sets Load Balancer (e.g. Basic
or Standard
). Alternatively, you may use the public_ip_prefix_id
field to generate instance-level IPs in a virtual machine scale set as well. The zonal properties of the prefix will be passed to the Virtual Machine instance IPs, though they will not be shown in the output. To view the public IP addresses assigned to the Virtual Machine Scale Sets Virtual Machine instances use the az vmss list-instance-public-ips --resource-group ResourceGroupName
--name VirtualMachineScaleSetName
CLI command.
-> Note: When using this field you'll also need to configure a Rule for the Load Balancer, and use a depends_on
between this resource and the Load Balancer Rule.
load_balancer_inbound_nat_rules_ids
- (Optional) A list of NAT Rule ID's from a Load Balancer which this Virtual Machine Scale Set should be connected to.
-> Note: When using this field you'll also need to configure a Rule for the Load Balancer, and use a depends_on
between this resource and the Load Balancer Rule.
primary
- (Optional) Is this the Primary IP Configuration for this Network Interface? Defaults tofalse
.
-> Note: One ip_configuration
block must be marked as Primary for each Network Interface.
-
public_ip_address
- (Optional) Apublic_ip_address
block as defined below. -
subnet_id
- (Optional) The ID of the Subnet which this IP Configuration should be connected to.
-> subnet_id
is required if version
is set to IPv4
.
version
- (Optional) The Internet Protocol Version which should be used for this IP Configuration. Possible values areIPv4
andIPv6
. Defaults toIPv4
.
An ip_tag
block supports the following:
-
tag
- (Required) The IP Tag associated with the Public IP, such asSQL
orStorage
. Changing this forces a new resource to be created. -
type
- (Required) The Type of IP Tag, such asFirstPartyUsage
. Changing this forces a new resource to be created.
A network_interface
block supports the following:
-
name
- (Required) The Name which should be used for this Network Interface. Changing this forces a new resource to be created. -
ip_configuration
- (Required) One or moreip_configuration
blocks as defined above. -
dns_servers
- (Optional) A list of IP Addresses of DNS Servers which should be assigned to the Network Interface. -
enable_accelerated_networking
- (Optional) Does this Network Interface support Accelerated Networking? Defaults tofalse
. -
enable_ip_forwarding
- (Optional) Does this Network Interface support IP Forwarding? Defaults tofalse
. -
network_security_group_id
- (Optional) The ID of a Network Security Group which should be assigned to this Network Interface. -
primary
- (Optional) Is this the Primary IP Configuration?
-> Note: If multiple network_interface
blocks are specified, one must be set to primary
.
An os_disk
block supports the following:
-
caching
- (Required) The Type of Caching which should be used for the Internal OS Disk. Possible values areNone
,ReadOnly
andReadWrite
. -
storage_account_type
- (Required) The Type of Storage Account which should back this the Internal OS Disk. Possible values includeStandard_LRS
,StandardSSD_LRS
,StandardSSD_ZRS
,Premium_LRS
andPremium_ZRS
. Changing this forces a new resource to be created. -
diff_disk_settings
- (Optional) Adiff_disk_settings
block as defined above. Changing this forces a new resource to be created. -
disk_encryption_set_id
- (Optional) The ID of the Disk Encryption Set which should be used to encrypt this OS Disk. Conflicts withsecure_vm_disk_encryption_set_id
. Changing this forces a new resource to be created.
-> Note: The Disk Encryption Set must have the Reader
Role Assignment scoped on the Key Vault - in addition to an Access Policy to the Key Vault
-> Note: Disk Encryption Sets are in Public Preview in a limited set of regions
disk_size_gb
- (Optional) The Size of the Internal OS Disk in GB, if you wish to vary from the size used in the image this Virtual Machine Scale Set is sourced from.
-> Note: If specified this must be equal to or larger than the size of the Image the VM Scale Set is based on. When creating a larger disk than exists in the image you'll need to repartition the disk to use the remaining space.
secure_vm_disk_encryption_set_id
- (Optional) The ID of the Disk Encryption Set which should be used to Encrypt the OS Disk when the Virtual Machine Scale Set is Confidential VMSS. Conflicts withdisk_encryption_set_id
. Changing this forces a new resource to be created.
-> Note: secure_vm_disk_encryption_set_id
can only be specified when security_encryption_type
is set to DiskWithVMGuestState
.
security_encryption_type
- (Optional) Encryption Type when the Virtual Machine Scale Set is Confidential VMSS. Possible values areVMGuestStateOnly
andDiskWithVMGuestState
. Changing this forces a new resource to be created.
-> Note: vtpm_enabled
must be set to true
when security_encryption_type
is specified.
-> Note: encryption_at_host_enabled
cannot be set to true
when security_encryption_type
is set to DiskWithVMGuestState
.
write_accelerator_enabled
- (Optional) Should Write Accelerator be Enabled for this OS Disk? Defaults tofalse
.
-> Note: This requires that the storage_account_type
is set to Premium_LRS
and that caching
is set to None
.
A plan
block supports the following:
-
name
- (Required) Specifies the name of the image from the marketplace. Changing this forces a new resource to be created. -
publisher
- (Required) Specifies the publisher of the image. Changing this forces a new resource to be created. -
product
- (Required) Specifies the product of the image from the marketplace. Changing this forces a new resource to be created.
A scale_in
block supports the following:
-
rule
- (Optional) The scale-in policy rule that decides which virtual machines are chosen for removal when a Virtual Machine Scale Set is scaled in. Possible values for the scale-in policy rules areDefault
,NewestVM
andOldestVM
, defaults toDefault
. For more information about scale in policy, please refer to this doc. -
force_deletion_enabled
- (Optional) Should the virtual machines chosen for removal be force deleted when the virtual machine scale set is being scaled-in? Possible values aretrue
orfalse
. Defaults tofalse
.
A protected_settings_from_key_vault
block supports the following:
-
secret_url
- (Required) The URL to the Key Vault Secret which stores the protected settings. -
source_vault_id
- (Required) The ID of the source Key Vault.
A public_ip_address
block supports the following:
-
name
- (Required) The Name of the Public IP Address Configuration. -
domain_name_label
- (Optional) The Prefix which should be used for the Domain Name Label for each Virtual Machine Instance. Azure concatenates the Domain Name Label and Virtual Machine Index to create a unique Domain Name Label for each Virtual Machine. -
idle_timeout_in_minutes
- (Optional) The Idle Timeout in Minutes for the Public IP Address. Possible values are in the range4
to32
. -
ip_tag
- (Optional) One or moreip_tag
blocks as defined above. Changing this forces a new resource to be created. -
public_ip_prefix_id
- (Optional) The ID of the Public IP Address Prefix from where Public IP Addresses should be allocated. Changing this forces a new resource to be created.
-> Note: This functionality is in Preview and must be opted into via az feature register --namespace Microsoft.Network --name AllowBringYourOwnPublicIpAddress
and then az provider register -n Microsoft.Network
.
version
- (Optional) The Internet Protocol Version which should be used for this public IP address. Possible values areIPv4
andIPv6
. Defaults toIPv4
. Changing this forces a new resource to be created.
A rolling_upgrade_policy
block supports the following:
-
cross_zone_upgrades_enabled
- (Optional) Should the Virtual Machine Scale Set ignore the Azure Zone boundaries when constructing upgrade batches? Possible values aretrue
orfalse
. -
max_batch_instance_percent
- (Required) The maximum percent of total virtual machine instances that will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, unhealthy instances in previous or future batches can cause the percentage of instances in a batch to decrease to ensure higher reliability. -
max_unhealthy_instance_percent
- (Required) The maximum percentage of the total virtual machine instances in the scale set that can be simultaneously unhealthy, either as a result of being upgraded, or by being found in an unhealthy state by the virtual machine health checks before the rolling upgrade aborts. This constraint will be checked prior to starting any batch. -
max_unhealthy_upgraded_instance_percent
- (Required) The maximum percentage of upgraded virtual machine instances that can be found to be in an unhealthy state. This check will happen after each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. -
pause_time_between_batches
- (Required) The wait time between completing the update for all virtual machines in one batch and starting the next batch. The time duration should be specified in ISO 8601 format. -
prioritize_unhealthy_instances_enabled
- (Optional) Upgrade all unhealthy instances in a scale set before any healthy instances. Possible values aretrue
orfalse
. -
maximum_surge_instances_enabled
- (Optional) Create new virtual machines to upgrade the scale set, rather than updating the existing virtual machines. Existing virtual machines will be deleted once the new virtual machines are created for each batch. Possible values aretrue
orfalse
.
-> Note: overprovision
must be set to false
when maximum_surge_instances_enabled
is specified.
A secret
block supports the following:
-
certificate
- (Required) One or morecertificate
blocks as defined above. -
key_vault_id
- (Required) The ID of the Key Vault from which all Secrets should be sourced.
A termination_notification
block supports the following:
-
enabled
- (Required) Should the termination notification be enabled on this Virtual Machine Scale Set? -
timeout
- (Optional) Length of time (in minutes, between 5 and 15) a notification to be sent to the VM on the instance metadata server till the VM gets deleted. The time duration should be specified in ISO 8601 format. Defaults toPT5M
.
-> Note: For more information about the termination notification, please refer to this doc.
A winrm_listener
block supports the following:
certificate_url
- (Optional) The Secret URL of a Key Vault Certificate, which must be specified whenprotocol
is set toHttps
. Changing this forces a new resource to be created.
-> Note: This can be sourced from the secret_id
field within the azurerm_key_vault_certificate
Resource.
protocol
- (Required) The Protocol of the WinRM Listener. Possible values areHttp
andHttps
. Changing this forces a new resource to be created.
A source_image_reference
block supports the following:
-
publisher
- (Required) Specifies the publisher of the image used to create the virtual machines. Changing this forces a new resource to be created. -
offer
- (Required) Specifies the offer of the image used to create the virtual machines. Changing this forces a new resource to be created. -
sku
- (Required) Specifies the SKU of the image used to create the virtual machines. -
version
- (Required) Specifies the version of the image used to create the virtual machines.
A spot_restore
block supports the following:
-
enabled
- (Optional) Should the Spot-Try-Restore feature be enabled? The Spot-Try-Restore feature will attempt to automatically restore the evicted Spot Virtual Machine Scale Set VM instances opportunistically based on capacity availability and pricing constraints. Possible values aretrue
orfalse
. Defaults tofalse
. Changing this forces a new resource to be created. -
timeout
- (Optional) The length of time that the Virtual Machine Scale Set should attempt to restore the Spot VM instances which have been evicted. The time duration should be between15
minutes and120
minutes (inclusive). The time duration should be specified in the ISO 8601 format. Defaults toPT1H
. Changing this forces a new resource to be created.
In addition to the Arguments listed above - the following Attributes are exported:
-
id
- The ID of the Windows Virtual Machine Scale Set. -
identity
- Aidentity
block as defined below. -
unique_id
- The Unique ID for this Windows Virtual Machine Scale Set.
A identity
block exports the following:
-
principal_id
- The Principal ID associated with this Managed Service Identity. -
tenant_id
- The Tenant ID associated with this Managed Service Identity.
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 60 minutes) Used when creating the Windows Virtual Machine Scale Set.read
- (Defaults to 5 minutes) Used when reading the Windows Virtual Machine Scale Set.update
- (Defaults to 60 minutes) Used when updating (and rolling the instances of) the Windows Virtual Machine Scale Set (e.g. when changing SKU).delete
- (Defaults to 60 minutes) Used when deleting the Windows Virtual Machine Scale Set.
Windows Virtual Machine Scale Sets can be imported using the resource id
, e.g.
terraform import azurerm_windows_virtual_machine_scale_set.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleset1