hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

Support for Spot Priority Mix for high availability and cost savings using terraform #24184

Open githubofkrishnadhas opened 11 months ago

githubofkrishnadhas commented 11 months ago

Is there an existing issue for this?

Community Note

Description

Hi Team,

Microsoft azure has implemented spot mix along with ondemand machines for VMSS. we can define the ondemand / regular VM which are un interruptable and we can specify percentage of spot instances in the vmss for rest of instances.

while checking terraform i dont see this implemented yet. please have a look,

These are the links: https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/spot-priority-mix?tabs=portal

https://techcommunity.microsoft.com/t5/azure-compute/announcing-general-availability-of-spot-priority-mix-for-azure/m-p/3765160

New or Affected Resource(s)/Data Source(s)

NA

Potential Terraform Configuration

this is the corresponding arm template config

https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/spot-priority-mix?tabs=portal#arm-template

"priorityMixPolicy": {
    "baseRegularPriorityCount": 0,
    "regularPriorityPercentageAboveBase": 50
}

Parameters:

baseRegularPriorityCount – Specifies a base number of VMs that are standard, Regular priority; if the Scale Set capacity is at or below this number, all VMs are Regular priority.
regularPriorityPercentageAboveBase – Specifies the percentage split of Regular and Spot priority VMs that are used when the Scale Set capacity is above the baseRegularPriorityCount.

References

this will be a great help for teams using vmss to reduce the cost and at same time have high uptime for application. Spot mix will reduce the cost drastically.

rcskosir commented 11 months ago

Thank you for taking the time to open this feature request!

harshavmb commented 10 months ago

Hi @githubofkrishnadhas ,

It appears to me that it's already available as part of azurerm_orchestrated_virtual_machine_scale_set resource & link to docs here.

githubofkrishnadhas commented 10 months ago

Thanks @harshavmb for pointing it out its available in azurerm_orchestrated_virtual_machine_scale_set .

we are using azurerm_linux_virtual_machine_scale_set in our modules https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine_scale_set.

is it too much to ask you if you can add the functionality over this as well?

in the mean time i will definitely try out thè one you have shared above.

githubofkrishnadhas commented 10 months ago

Thank you. I was going through the documentation and understood why spot mix feature is not there in azurerm_linux_virtual_machine_scale_set.