Skip to main content

More Info:

Ensure that your Microsoft Azure virtual machine scale sets are configured to receive instance termination notifications through the Azure Metadata service and have a predefined delay timeout configured for the Terminate operation (event). The termination notifications are delivered through Scheduled Events, an Azure Metadata feature which sends termination notifications, and can also be used to delay impactful operations such as reboots and redeployments. The delay associated with the Terminate event will depend on the delay limit specified in the VM scale set model configuration.

Risk Level

Medium

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Using Console

Sure, Here are the step by step instructions to remediate the misconfiguration “Enable Instance Termination Notifications For Virtual Machine Scale Sets” in AZURE using the AZURE console:
  1. Open the AZURE portal and log in to your account.
  2. Navigate to the Virtual Machine Scale Sets blade.
  3. Select the Virtual Machine Scale Set for which you want to enable the instance termination notifications.
  4. In the Virtual Machine Scale Set blade, click on the “Auto Scale” option from the left-hand side menu.
  5. In the “Auto Scale” blade, click on the “Notifications” tab.
  6. In the “Notifications” tab, click on the “Add notification” button.
  7. In the “Add notification” blade, select “Email” as the notification type.
  8. Enter the email address of the recipient(s) who will receive the notification in the “Email addresses” field.
  9. In the “Email subject” field, enter a subject line for the notification email.
  10. In the “Email body” field, enter the message you want to include in the notification email.
  11. Click on the “OK” button to save the notification settings.
That’s it! You have now enabled the instance termination notifications for your Virtual Machine Scale Set in AZURE. Whenever an instance is terminated, the configured recipient(s) will receive an email notification.

To remediate the misconfiguration “Enable Instance Termination Notifications For Virtual Machine Scale Sets” in Azure using Azure CLI, you can follow the below steps:Step 1: Open the Azure CLI command prompt or terminal.Step 2: Run the following command to enable the instance termination notifications for virtual machine scale sets:
Note: Replace <resource-id> with the resource ID of the virtual machine scale set and <email-address> with the email address of the administrator.Step 3: Verify the instance termination notification settings by running the following command:
Note: Replace <resource-id> with the resource ID of the virtual machine scale set.Step 4: Ensure that the “notifications” property in the output of the above command contains the email address of the administrator.With these steps, you have successfully remediated the misconfiguration “Enable Instance Termination Notifications For Virtual Machine Scale Sets” in Azure using Azure CLI.
To remediate the misconfiguration “Enable Instance Termination Notifications For Virtual Machine Scale Sets” for AZURE using Python, you can follow the below steps:
  1. Import the required libraries:
  1. Authenticate the client:
  1. Get the VM Scale Set ID:
  1. Create an action group:
  1. Get the action group ID:
  1. Enable termination notifications for the VM Scale Set:
These steps will enable instance termination notifications for the specified VM Scale Set in Azure using Python.
If this is a azurerm_windows_virtual_machine_scale_set, use the same termination_notification block inside that resource instead.This change is in-place and does not force replacement of the VM scale set; existing instances will honor scheduled events after the model is updated.Verification: terraform plan should show the termination_notification block being added (or enabled changing to true and timeout to your chosen value) on the relevant azurerm_*_virtual_machine_scale_set resource, with no -/+ replacement of the scale set.