VM Scale Sets for auto scaling in Azure - Mini Project: Build & Apply
Create an Azure VM Scale Set resource named myScaleSet in the eastus region. Use the VM size Standard_DS1_v2 and the image UbuntuLTS. Define the scale set with a capacity of 2 instances.
Use the azurerm_linux_virtual_machine_scale_set resource with the exact name myScaleSet. Set location to eastus, sku to Standard_DS1_v2, and instances to 2. Use the Ubuntu 18.04 LTS image from Canonical.
Create a variable called autoscale_min and set it to 2. Create another variable called autoscale_max and set it to 5. These will define the minimum and maximum number of VM instances for autoscaling.
Use Terraform variable blocks named exactly autoscale_min and autoscale_max with default values 2 and 5 respectively.
Create an autoscale setting resource named myAutoscaleSetting linked to the VM Scale Set myScaleSet. Add a rule to increase instances by 1 when average CPU percentage is above 70% for 5 minutes. Add another rule to decrease instances by 1 when average CPU percentage is below 30% for 5 minutes.
Use the azurerm_monitor_autoscale_setting resource named myAutoscaleSetting. Link it to the VM Scale Set using target_resource_id. Add two rules: one to increase instances when CPU > 70%, and one to decrease when CPU < 30%. Use 5 minutes cooldowns.
In the autoscale setting myAutoscaleSetting, ensure the default capacity is set to 2. Set the cooldown period for both scale actions to PT5M (5 minutes). Confirm the autoscale setting is fully configured with these values.
Check that the capacity block has default = "2". Both scale_action blocks should have cooldown = "PT5M".