When I am trying to create new version for Azure Share Image in the Image Gallery by changing “Name” parameter to 1.0.2 in azurerm_shared_image_version resource then my 1.0.1 version is getting destroyed first and 1.0.2 version is getting created.
Below is my sample code.
data “azurerm_snapshot” “demo_snapshot” {
name = “MD_snapshot1”
resource_group_name = “WestUs_rg”
}
data “azurerm_shared_image” “demo_sharedimage” {
name = “Specialized_ManagedDisk_Image”
gallery_name = “MD_Gallery”
resource_group_name = “WestUS_rg”
}
resource “azurerm_shared_image_version” “Demoversion” {
name = “1.0.1”
gallery_name = data.azurerm_shared_image.demo_sharedimage.gallery_name
image_name = data.azurerm_shared_image.demo_sharedimage.name
resource_group_name = data.azurerm_shared_image.demo_sharedimage.resource_group_name
location = data.azurerm_shared_image.demo_sharedimage.location
os_disk_snapshot_id = data.azurerm_snapshot.demo_snapshot.id
target_region {
name = data.azurerm_shared_image.demo_sharedimage.location
regional_replica_count = 1
storage_account_type = "Standard_LRS"
}
target_region {
name = "EastUS"
regional_replica_count = 1
storage_account_type = "Standard_LRS"
}
}