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

Terraform - Azure: Attach Existing Disk - Changing property 'dataDisk.name' is not allowed #592

Closed
akamalov opened this issue Nov 30, 2017 · 3 comments
Labels

Comments

@akamalov
Copy link

akamalov commented Nov 30, 2017

Greetings,

Environment:

- Terraform v0.11.0
- provider.azurerm v0.3.3
- provider.tls v1.0.1
- RHEL 7.2
- Kernel: 3.10.0-327.4.4.el7.x86_64

Problem:

Trying to attach an existing disk on VM being provisioned on Azure, getting error as such:

* azurerm_virtual_machine.kafka_vm: 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.name' is not allowed."

Here is vm.tf snippet:

storage_data_disk {
    name            = "${var.env_short_name}-kafka-data01"
    managed_disk_id = "${var.kafka_data_image_id}"
    create_option   = "Attach"
    disk_size_gb  = "30"
    lun             = 5
  }

..where managed_disk_id is a variable (i.e., $var.kafka_data_image_id) defined with a full path to the existing disk. Example:

kafka_data_image_id  = "/subscriptions/XXXXX-fcf3-4ec6-b598-XXXXXXXXXXXX/resourceGroups/TEST-Environment-test0001-rg/providers/Microsoft.Compute/disks/test1-kafka-data01"

I tried to provide ""for the name, but it errored out telling me that I must provide name. Any pointers on what am I doing wrong? Could it be that a problem is related to #85

Thanks!!

@akamalov
Copy link
Author

Answering my own question: It looks like if disk_size_gb is provided wrong (i.e., existing disk_size_gb = 20, but provided in terraform plan the number is wrong - example 30 ), then Terraform errors out with this obscure message. The problem is not in disk name, but in disk size, however reported message references the name of the disk

@passionatedevops
Copy link

I was facing the same issue

Error: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- 

Original Error: autorest/azure: Service returned an error. Status=<nil> Code="PropertyChangeNotAllowed" Message="Changing property 'dataDisk.createOption' is not allowed." Target="dataDisk.createOption"

  on modules/ApplicationServer/main.tf line 25, in resource "azurerm_virtual_machine" "main-rg__appvm":
  25: resource azurerm_virtual_machine main-rg__appvm {

I tried this and got solved.

storage_data_disk {
    name              = "datadisk-1"
    lun               = 1
    create_option     = "Attach"
    disk_size_gb      = "1023"
    managed_disk_type = "StandardSSD_LRS"
}

If you are already using create_option = "Attach", try this create_option = "Empty" under storage_data_disk section

@ghost
Copy link

ghost commented Feb 10, 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 👉 [email protected]. Thanks!

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

No branches or pull requests

3 participants