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

Force recreation if storage_data_disk.creation_option changes (#218) #240

Merged
merged 4 commits into from
Aug 11, 2017

Conversation

tombuildsstuff
Copy link
Contributor

Re-opening #218

Rebased and added a commit to the end of #218 which apparently closed the original PR - re-opening this here

Original issue body from #218:


I'm not sure how to test this change, please provide any feedback to help me with it.

Azure Resource Manager API doesn't support changes to this field. It
should recreate the virtual machine and attach the disks again.

Actual Behaviour:

module.xpto.azurerm_virtual_machine.prometheus_virtual_machine:
Modifying... (ID: /subscriptions/xxxxx...ute/virtualMachines/vm)
delete_data_disks_on_termination: "" => "false"
delete_os_disk_on_termination: "" => "true"
storage_data_disk.0.create_option: "Empty" => "Attach"
storage_data_disk.1.create_option: "Empty" => "Attach"
tags.%: "0" => "1"
tags.role: "" => "xpto"
Error applying plan:

1 error(s) occurred:

  • module.xpto.azurerm_virtual_machine.vm: 1 error(s) occurred:

  • azurerm_virtual_machine.prometheus_virtual_machine:
    compute.VirtualMachinesClient#CreateOrUpdate: Failure responding to
    request: StatusCode=409 -- Original Error: autorest/azure: Service
    returned an error. Status=409 Code="PropertyChangeNotAllowed"
    Message="Changing property 'dataDisk.createOption' is not allowed."

thiagocaiubi and others added 3 commits August 11, 2017 12:03
Azure Resource Manager API doesn't support changes to this field. It
should recreate the virtual machine and attach the disks again.

module.xpto.azurerm_virtual_machine.prometheus_virtual_machine:
Modifying... (ID: /subscriptions/xxxxx...ute/virtualMachines/vm)
  delete_data_disks_on_termination:  "" => "false"
  delete_os_disk_on_termination:     "" => "true"
  storage_data_disk.0.create_option: "Empty" => "Attach"
  storage_data_disk.1.create_option: "Empty" => "Attach"
  tags.%:                            "0" => "1"
  tags.role:                         "" => "xpto"
Error applying plan:

1 error(s) occurred:

* module.xpto.azurerm_virtual_machine.vm: 1 error(s) occurred:

* azurerm_virtual_machine.prometheus_virtual_machine:
compute.VirtualMachinesClient#CreateOrUpdate: Failure responding to
request: StatusCode=409 -- Original Error: autorest/azure: Service
returned an error. Status=409 Code="PropertyChangeNotAllowed"
Message="Changing property 'dataDisk.createOption' is not allowed."
@tombuildsstuff
Copy link
Contributor Author

Tests pass:

$ TF_ACC=1 envchain azurerm go test ./azurerm -v -timeout 120m -run TestAccAzureRMVirtualMachine_changeStorageDataDiskCreationOption
=== RUN   TestAccAzureRMVirtualMachine_changeStorageDataDiskCreationOption
--- PASS: TestAccAzureRMVirtualMachine_changeStorageDataDiskCreationOption (748.66s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	748.676s

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than 1 suggestion this LGTM.

Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &afterUpdate),
testAccCheckVirtualMachineRecreated(t, &afterCreate, &afterUpdate),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a state check for the field that's being patched in this PR, just for sanity...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@tombuildsstuff
Copy link
Contributor Author

Updated tests:

$ TF_ACC=1 envchain azurerm go test ./azurerm -v -timeout 120m -run TestAccAzureRMVirtualMachine_changeStorageDataDiskCreationOption
=== RUN   TestAccAzureRMVirtualMachine_changeStorageDataDiskCreationOption
--- PASS: TestAccAzureRMVirtualMachine_changeStorageDataDiskCreationOption (870.00s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	870.015s

@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants