[Similar ask] : Terraform plan destroying and replacing Azure VM upon rerun for a custom image stored in Shared Image Gallery
I am trying to create VMs using TFE and managed disks based on a Shared image gallery image however when using :
storage_image_reference {
id = var.latest-image-id
}
storage_os_disk {
name = var.storage_os_disk_name
create_option = "FromImage"
managed_disk_type = var.managed_disk_type
disk_size_gb = var.disk_size_gb
os_type = var.os_type
}
The disk does not go into the state and therefore cannot be updated with a new image
When using :
resource "azurerm_managed_disk" "vmdisk" {
name = var.storage_os_disk_name
location = var.location
resource_group_name = var.resource_group_name
storage_account_type = var.managed_disk_type
create_option = "FromImage"
image_reference_id = var.latest-image-id
disk_size_gb = var.disk_size_gb
tags = var.common_tags
}
resource "azurerm_virtual_machine" "vm" {
storage_os_disk {
name = var.storage_os_disk_name
create_option = "Attach"
managed_disk_id = azurerm_managed_disk.vmdisk.id
}
This errors with :
Error: Error creating/updating Managed Disk "1imutsbdsk0101" (Resource Group "x-xxx-xxx-xxx-xx-xxx"): compute.DisksClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="InvalidParameter" Message="The value of parameter imageReference is invalid." Target="/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/x-xxx-xxx-xx-xx-xxx/providers/Microsoft.Compute/galleries/xxxxxxx/images/xxxxx_Windows_2019_Mutable/versions/0.xx4.xxx"
I haven't seen any actual answer to this issue: