Open unkinected opened 9 months ago
FYI this one is still happening on azurerm v3.103.1
I would say this is an error happening in the API. I am using azapi_resource
for the same scenario you have and I am getting the same error even though the plan shows no changes.
Is there an existing issue for this?
Community Note
Terraform Version
1.6.6
AzureRM Provider Version
3.86.0
Affected Resource(s)/Data Source(s)
azurerm_virtual_machine
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Actual Behaviour
This VM was created from a backup of an older VM, and as such I have to use the azurerm_virtual_machine resource instead of azurerm_windows_virtual_machine (due to https://github.com/hashicorp/terraform-provider-azurerm/issues/8794). This machine had already been in my Terraform state for awhile and had been operating fine with previous versions of the azurerm provider.
I upgraded the azurerm provider from 3.83 to 3.86 and that's when this problem started happening.
Whenever I run a plan after upgrading, terraform cloud shows that this VM will be modified, but expanding the plan shows no attributes actually changing. The os_profile section is of course redacted in the plan due to secrets, so I'm assuming that it is trying to change this in the plan but I just can't see it.
Then when I do apply, I get the error:
Error: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=409 -- Original Error: Code="PropertyChangeNotAllowed" Message="Changing property 'osProfile' is not allowed." Target="osProfile"
Note that I haven't touched this VM. I would not expect it to show up in the plan at all. Removing the os_profile block doesn't fix - the same error appears. Looking at the json export of the VM from within the Azure portal does include an osProfile block, so there is values there (i.e. it's not null).
You can see that I've tried to ignore the os_profile block but that does nothing. Per another issue, it seems ignoring that block doesn't work in the azurerm_virtual_machine resource.
I tried downgrading back to 3.83 but unfortunately the problem persists. Also tried on terraform v1.5.7 and that was the same.
Steps to Reproduce
Important Factoids
No response
References
https://github.com/hashicorp/terraform-provider-azurerm/issues/8794 https://github.com/hashicorp/terraform-provider-azurerm/issues/3592