My employer’s IT department is very strict. When a virtual machine is created, alert rules must be applied. There is a brief 5-10 minute grace period, but when the Azure policy and other monitoring tools find a newly created VM without, for example, CPU Utilization % alert then the VM is quarantined/stopped/removed which will cause the packer build to disconnect and fail.
I’m working with the IT Security team in finding a resolution that they would find acceptable. Ideas include… a Special Vnet, an Exception or longer grace period for resource groups and images that begin with ‘pkr’.
Of course their first response was to add the necessary alerts to the running VM that packer has created.
To add a CPU % alert rule, I’ve tried a few ways to get the name of the VM and the resource group from packer to set environment variables using the shell-local provisioner and the azure-cli. This is just one example. I’ve also tried to reference the ${build. } map as well.
After re-reading the documentation a few times, I tried using the temp_compute_name and temp_resource_group_name. I was expecting to be able to get the names generated by packer but if I generate the names myself then I will know the names.