Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_virtual_machine_data_disk_attachment.create_option does not support Copy or FromImage #12032

Open
dannystaple opened this issue Jun 1, 2021 · 2 comments

Comments

@dannystaple
Copy link
Contributor

dannystaple commented Jun 1, 2021

Real world azurerm_virtual_machine_data_disk_attachment is able to be in values that the terraform resource can not match. This forces the use of ignore_changes workarounds for these items.

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.7
+ provider registry.terraform.io/hashicorp/azurerm v2.58.0
+ provider registry.terraform.io/hashicorp/external v1.2.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.1.0
+ provider registry.terraform.io/meilleursagents/ansiblevault v2.2.0

Your version of Terraform is out of date! The latest version
is 0.15.4. You can update by downloading from https://www.terraform.io/downloads.html

Affected Resource(s)

  • azurerm_virtual_machine_data_disk_attachment

Terraform Configuration Files

resource "azurerm_virtual_machine_data_disk_attachment" "vm_disk_attachment" {
  create_option = "Copy"
  managed_disk_id    = azurerm_managed_disk.vm_data_disk["myvm_disk"].id
  virtual_machine_id = azurerm_windows_virtual_machine.vm["myvm].id
  lun                = "0"
  caching            = "None"
}

Expected Behaviour

I should be able to get a clean plan - this is an imported resource that should match the existing Azure.

Actual Behaviour

Error: expected create_option to be one of [Attach Empty], got FromImage

on common/azure_vms/vms.tf line 108, in resource "azurerm_virtual_machine_data_disk_attachment" "vm_disk_attachment":
108: resource "azurerm_virtual_machine_data_disk_attachment" "vm_disk_attachment" {

Steps to Reproduce

  1. Have existing azure infrastructure with VM's with disk attachments that have a create_option that is one of Copy or FromImage.
  2. terraform plan

Important Factoids

The code that validates in this way is at https://github.com/terraform-providers/terraform-provider-azurerm/blob/b18388439c159d5273acc03cdbe98ccd575c147b/azurerm/internal/services/compute/virtual_machine_data_disk_attachment_resource.go#L75

References

@wymangr
Copy link

wymangr commented Feb 15, 2023

@dannystaple I'm having the same issue. Trying to import an existing Azure disk that has azurerm_virtual_machine_data_disk_attachment create_option set to "FromImage" and the plan is coming back requiring the disk attachment to be replaced. Just curious (because this issue is old and doesn't look like anyone has attempted to fix) were you able to get around it?

@dannystaple
Copy link
Contributor Author

I am no longer with the client where this happened, however, the azapi terraform provider might be the answer here. https://registry.terraform.io/providers/Azure/azapi/latest/docs - decribes as an "escape hatch" for times that AzureRM provider is not fully compatible/capable with regards to the Azure API's and with a tool to verify and update such items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants