Terraform-provider-azurerm: InvalidParameter Error when turning azurerm_shared_image_version into azurerm_managed_disk

Created on 15 Dec 2020  ·  7Comments  ·  Source: terraform-providers/terraform-provider-azurerm

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

  • Terraform v0.14.2
  • azurerm v2.40.0

Affected Resource(s)

  • azurerm_managed_disk

Terraform Configuration Files

resource "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
}

Debug Output

Debug Output Gist

Expected Behaviour


Managed disk should've been created on Azure.

Actual Behaviour

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"
  }
}
question servicdisks

All 7 comments

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.

https://social.technet.microsoft.com/Forums/ie/en-US/88bd9ca8-0e35-46f2-888c-3df05000cfb4/azure-arm-deployment-vm-creation-from-shared-image-gallery-image-errors?forum=iaas

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.

https://social.technet.microsoft.com/Forums/ie/en-US/88bd9ca8-0e35-46f2-888c-3df05000cfb4/azure-arm-deployment-vm-creation-from-shared-image-gallery-image-errors?forum=iaas

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.

Was this page helpful?
0 / 5 - 0 ratings