azurerm_managed_diskresource "azurerm_managed_disk" "example" {
name = "abm-disk"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
storage_account_type = "Standard_LRS"
create_option = "FromImage"
image_reference_id = azurerm_shared_image_version.example.id
}
Managed disk should've been created on Azure.
terraform apply of given resource fails with InvalidParameter Error, but what I understand is that one can create managed disk out of shared image version when using FromImage create option.
Moreover I'm able to create managed disk with az:
az disk create --resource-group AppSource-sandbox --location northeurope --name test-disk --gallery-image-reference /subscriptions/<subscription_id>/resourceGroups/AppSource-sandbox/providers/Microsoft.Compute/galleries/image_gallery/images/shared-abm-image/versions/1.0.0
P.S. This is my shared image version resource:
resource "azurerm_shared_image_version" "example" {
name = "1.0.0"
gallery_name = azurerm_shared_image.example.gallery_name
image_name = azurerm_shared_image.example.name
resource_group_name = azurerm_shared_image.example.resource_group_name
location = azurerm_shared_image.example.location
managed_image_id = data.azurerm_image.packer-image.id
target_region {
name = azurerm_shared_image.example.location
regional_replica_count = 2
storage_account_type = "Standard_LRS"
}
}
Just came across this issue myself today too, from a bit of research people are reporting it is to do with the Azure API version being used.
Just came across this issue myself today too, from a bit of research people are reporting it is to do with the Azure API version being used.
Interesting point. Unfortunately Azure API version is hard-coded into the azurerm provider code and therefore cannot be changed. From skimming the debug output it turns out that azurerm v2.40.0 uses API version 2020-05-01.
hi @Robzzson
Thanks for opening this issue.
Unfortunately Azure overloads the term "image" multiple times, there's an "Image" (which is a snapshot of a Virtual Machine) and a "Shared Image" (which is a reusable version of said image, housed inside a Shared Image Gallery). In this instance the FromImage value for this refers to an azurerm_image rather than an azurerm_shared_image or azurerm_shared_image_version - which is why this is returning a ParameterError from the Azure API here.
Within Terraform we're gradually working through the Provider adding more specific validation for resources to try and make this clearer - however there's no timeframe for this to be completed across all resources, as such I believe that this'd be caught at terraform plan time in the future - and as such I'm going to close this issue for the moment.
A Shared Image (Version) can be provisioned using a Virtual Machine onto a new OS Disk - my understanding is that it's not possible to do this without provisioning a Virtual Machine ahead of time. That said, it should be possible to use a tool like Packer to provision a Virtual Machine using this Shared Image (Version) and capture this OS Disk should you need to do so.
Since this is a question regarding usage, rather than a bug in the Azure Provider - I'm going to close this issue for the moment - but should you have further questions I'd point you towards the community forum where someone should be able to assist further.
Thanks!
Dear @tombuildsstuff
Thank you for your explanation.
Lemme express one more thing before we close this issue. I did a little more research and stumbled upon this article (see "Create Azure Managed Disk from Shared Image Gallery" section of the article), where the author is doing a very similar thing to mine. There's even an author's comment suggesting that the conversion shared image version -> OS disk is indeed possible without spinning up entirely new VM. This is by the way what I showcased in my initial comment when using az disk create .... Having said that, wouldn't this issue turn into feature request, where such a conversion using Terraform is possible?
@Robzzson it's possible that we could expose a new field to support this use-case specifically - feel free to open a new Feature Request if your looking for support for that :)
@Robbzzson please can you mention me on that, would be happy to raise a PR
for it
On Wed, 16 Dec 2020 at 12:45, Tom Harvey notifications@github.com wrote:
@Robzzson https://github.com/Robzzson it's possible that we could
expose a new field to support this use-case specifically - feel free to
open a new Feature Request if your looking for support for that :)—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/terraform-providers/terraform-provider-azurerm/issues/9880#issuecomment-746235800,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AJTG27LB6QFMJHNTTZNWVZLSVCTXDANCNFSM4U442TFA
.
@EAS-Rhys I'm just creating a feature request and I'll mention you as soon as I submit.