Closed qubeio closed 1 year ago
I have implemented lower for the OS disk but I cannot get data disks to work :
Could not update the properties of the virtual machine 'xx' because of following invalid disk Ids
but when i check the State the id matches the case the error and matches the id of the disk in Azure.
I cannot get this to work with lower, plan always wants to replace the dr due to diskid
This seems to be hitting the dependency behavior of Terraform data source https://www.terraform.io/language/data-sources#data-resource-dependencies if a data source directly depends on another managed resource, it will be recalculated during the apply phase because it doesn't know whether the upstream resource will change or not in the same apply. The workaround would be use a local value to create an independent dependency. e.g.: https://github.com/hashicorp/terraform-provider-azurerm/issues/13152#issuecomment-1050648704
And disk_id
is case-insensitive, so I guess tolower
is not needed
https://github.com/hashicorp/terraform-provider-azurerm/blob/19096cfe686c968c3784d67657debed8ee54a93c/internal/services/recoveryservices/site_recovery_replicated_vm_resource.go#L145
Thanks for your reply, I have tried to do this but to no avail I cannot get it to work!
Thanks for opening this issue. This was a problem in the 2.x version of the provider which is no longer actively maintained. If this is still an issue with the 3.x version of the provider please do let us know by opening a new issue, thanks!
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
Terraform (and AzureRM Provider) Version
Terraform v0.14.5 Azure RM 2.48
Affected Resource(s)
azurerm_zurerm_site_recovery_replicated_vm
Terraform Configuration Files
Debug Output
https://gist.github.com/AndreasFrangopoulos/aabb3e9fbeb83d81b2c094712be46702
Panic Output
Expected Behaviour
Actual Behaviour
TF should see that the refreshed data has not changed and not recreate the replicated vm.
From the debug output we can see that the data source is refreshing (I don't understand why this is happening either, but not important), but that data won't change, becuase the disk hasn't. I suspect that it's just the fact that there is a refresh happening that is causing the replacement. This could be avoided if we could reference the disk id directly from the vm resource rather than having to proxy through a data source, but this is also another story.
Here is a copy of the plan showing the new maanged disk data is identical to what was received from the Azure API in the debug output https://gist.github.com/AndreasFrangopoulos/c44577da3ce6c23bd820fd8fcee6e9ad
Steps to Reproduce
terraform apply
Important Factoids
References
8416
I had to use the solution in this ticket to force lower case disk names as I was having the same problem.
0000