Manages a Linux Virtual Machine Scale Set.
This example provisions a basic Linux Virtual Machine Scale Set on an internal network. Additional examples of how to use the azurestack_linux_virtual_machine_scale_set
resource can be found in the ./examples/vm-scale-set/linux` directory within the Github Repository.
provider "azurestack" {
features {}
}
resource "azurestack_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurestack_virtual_network" "example" {
name = "example-network"
resource_group_name = azurestack_resource_group.example.name
location = azurestack_resource_group.example.location
address_space = ["10.0.0.0/16"]
}
resource "azurestack_subnet" "internal" {
name = "internal"
resource_group_name = azurestack_resource_group.example.name
virtual_network_name = azurestack_virtual_network.example.name
address_prefix = "10.0.2.0/24"
}
resource "azurestack_linux_virtual_machine_scale_set" "example" {
name = "example-vmss"
resource_group_name = azurestack_resource_group.example.name
location = azurestack_resource_group.example.location
sku = "Standard_F2"
instances = 1
admin_username = "adminuser"
admin_ssh_key {
username = "adminuser"
public_key = file("~/.ssh/id_rsa.pub")
}
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
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 = azurestack_subnet.internal.id
}
}
}
The following arguments are supported:
name
- (Required) The name of the Linux Virtual Machine Scale Set. Changing this forces a new resource to be created.
location
- (Required) The Azure location where the Linux 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 Linux Virtual Machine Scale Set should be exist. 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.
sku
- (Required) The Virtual Machine SKU for the Scale Set, such as Standard_F2
.
network_interface
- (Required) One or more network_interface
blocks as defined below.
os_disk
- (Required) An os_disk
block as defined below.
additional_capabilities
- (Optional) A additional_capabilities
block as defined below.
admin_password
- (Optional) The Password which should be used for the local-administrator on this Virtual Machine. Changing this forces a new resource to be created.
admin_ssh_key
- (Optional) One or more admin_ssh_key
blocks as defined below.automatic_os_upgrade_policy
- (Optional) A automatic_os_upgrade_policy
block as defined below. This can only be specified when upgrade_mode
is set to Automatic
.
automatic_instance_repair
- (Optional) A automatic_instance_repair
block as defined below. To enable the automatic instance repair, this Virtual Machine Scale Set must have a valid health_probe_id
or an Application Health Extension.
boot_diagnostics
- (Optional) A boot_diagnostics
block as defined below.
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 the name
field. If the value of the name
field is not a valid computer_name_prefix
, then you must specify computer_name_prefix
.
custom_data
- (Optional) The Base64-Encoded Custom Data which should be used for this Virtual Machine Scale Set.
data_disk
- (Optional) One or more data_disk
blocks as defined below.
disable_password_authentication
- Should Password Authentication be disabled on this Virtual Machine Scale Set? Defaults to true
.
do_not_run_extensions_on_overprovisioned_machines
- (Optional) Should Virtual Machine Extensions be run on Overprovisioned Virtual Machines in the Scale Set? Defaults to false
.
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 more extension
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 when upgrade_mode
is set to Automatic
or Rolling
.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 to true
.
plan
- (Optional) A plan
block as documented below.
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.provision_vm_agent
- (Optional) Should the Azure VM Agent be provisioned on each Virtual Machine in the Scale Set? Defaults to true
. Changing this value forces a new resource to be created.
scale_in_policy
- (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 are Default
, NewestVM
and OldestVM
, defaults to Default
. For more information about scale in policy, please refer to this doc.
secret
- (Optional) One or more secret
blocks as defined below.
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 to true
.
source_image_id
- (Optional) The ID of an Image which each Virtual Machine in this Scale Set should be based on.
source_image_reference
- (Optional) A source_image_reference
block as defined below.tags
- (Optional) A mapping of tags which should be assigned to this Virtual Machine Scale Set.
terminate_notification
- (Optional) A terminate_notification
block as defined below.
upgrade_mode
- (Optional) Specifies how Upgrades (e.g. changing the Image/SKU) should be performed to Virtual Machine Instances. Possible values are Automatic
, Manual
and Rolling
. Defaults to Manual
.
A additional_capabilities
block supports the following:
ultra_ssd_enabled
- (Optional) Should the capacity to enable Data Disks of the UltraSSD_LRS
storage account type be supported on this Virtual Machine Scale Set? Defaults to false
. Changing this forces a new resource to be created.A admin_ssh_key
block supports the following:
public_key
- (Required) The Public Key which should be used for authentication, which needs to be at least 2048-bit and in ssh-rsa
format.
username
- (Required) The Username for which this Public SSH Key should be configured.
A 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?
A 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 (in minutes, between 30 and 90, defaults to 30 minutes) for which automatic repairs will be delayed. The grace period starts right after the VM is found unhealthy. The time duration should be specified in ISO 8601 format.
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.A certificate
block supports the following:
url
- (Required) The Secret URL of a Key Vault Certificate.A data_disk
block supports the following:
caching
- (Required) The type of Caching which should be used for this Data Disk. Possible values are None
, ReadOnly
and ReadWrite
.
create_option
- (Optional) The create option which should be used for this Data Disk. Possible values are Empty
and FromImage
. Defaults to Empty
. (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 include Standard_LRS
and Premium_LRS
.
disk_encryption_set_id
- (Optional) The ID of the Disk Encryption Set which should be used to encrypt this Data Disk.
write_accelerator_enabled
- (Optional) Should Write Accelerator be enabled for this Data Disk? Defaults to false
.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 is Local
. 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 to true
.
automatic_upgrade_enabled
- (Optional) Should the Extension be automatically updated whenever the Publisher releases a new version of this VM Extension? Defaults to false
.
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.
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.
A ip_configuration
block supports the following:
name
- (Required) The Name which should be used for this IP Configuration.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.primary
- (Optional) Is this the Primary IP Configuration for this Network Interface? Defaults to false
.subnet_id
- (Optional) The ID of the Subnet which this IP Configuration should be connected to.version
- (Optional) The Internet Protocol Version which should be used for this IP Configuration. Possible values are IPv4
and IPv6
. Defaults to IPv4
.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 more ip_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_ip_forwarding
- (Optional) Does this Network Interface support IP Forwarding? Defaults to false
.
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?
A os_disk
block supports the following:
caching
- (Required) The Type of Caching which should be used for the Internal OS Disk. Possible values are None
, ReadOnly
and ReadWrite
.
storage_account_type
- (Required) The Type of Storage Account which should back this the Internal OS Disk. Possible values include Standard_LRS
, StandardSSD_LRS
and Premium_LRS
.
diff_disk_settings
- (Optional) A diff_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.
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.write_accelerator_enabled
- (Optional) Should Write Accelerator be Enabled for this OS Disk? Defaults to false
.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 rolling_upgrade_policy
block supports the following:
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.
A secret
block supports the following:
certificate
- (Required) One or more certificate
blocks as defined above.
key_vault_id
- (Required) The ID of the Key Vault from which all Secrets should be sourced.
A terminate_notification
block supports the following:
enabled
- (Required) Should the terminate notification be enabled on this Virtual Machine Scale Set? Defaults to false
.
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.
source_image_reference
supports the following:
publisher
- (Optional) Specifies the publisher of the image used to create the virtual machines.
offer
- (Optional) Specifies the offer of the image used to create the virtual machines.
sku
- (Optional) Specifies the SKU of the image used to create the virtual machines.
version
- (Optional) Specifies the version of the image used to create the virtual machines.
In addition to all arguments above, the following attributes are exported:
id
- The ID of the Linux Virtual Machine Scale Set.
unique_id
- The Unique ID for this Windows Virtual Machine Scale Set.
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 60 minutes) Used when creating the Linux Virtual Machine Scale Set.read
- (Defaults to 5 minutes) Used when reading the Linux Virtual Machine Scale Set.update
- (Defaults to 60 minutes) Used when updating (and rolling the instances of) the Linux Virtual Machine Scale Set (e.g. when changing SKU).delete
- (Defaults to 60 minutes) Used when deleting the Linux Virtual Machine Scale Set.Linux Virtual Machine Scale Sets can be imported using the resource id
, e.g.
terraform import azurestack_linux_virtual_machine_scale_set.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleset1