The intermittent issue where Terraform is unable to create scaling rules on the virtual machine scale-sets because the metrics it requires for the rules are not found.
The issue is usually fixed by rerunning the deployment, but is there a way I can ensure the terraform code waits until the metric has been emitted by the dependent VM before creating the scaling rule?
The following error is thrown in Terraform (version 0.14.8):
Error: Error creating AutoScale Setting "Nuance Speech autoscale Setting - Percentage CPU" (Resource Group "rg-dev-eastus2-nuance"): insights.AutoscaleSettingsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="{"code":"BadRequest","message":"The requested metric defintions 'used_percent' were not found on '/subscriptions/XXX/resourceGroups/rg-dev-eastus2-nuance/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-speech-XX' in namespace 'telegraf/mem'."}"
on .terraform/modules/nuance_speech_linux_vmss_autoscale_rule/main.tf line 1, in resource "azurerm_monitor_autoscale_setting" "this_autoscale_setting": 2022-10-10T17:06:55.240Z [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" 1: resource "azurerm_monitor_autoscale_setting" "this_autoscale_setting" {