-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
resource azurerm_windows_virtual_machine has source_image dependiencies wrong #19614
Comments
Hi @siemin81 thanks for opening the issue. |
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. |
Is there an existing issue for this?
Community Note
Terraform Version
1.2.7
AzureRM Provider Version
3.34.0
Affected Resource(s)/Data Source(s)
azurerm_windows_virtual_machine
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
There is a possible configuration on Azure (when VM needs to be created from existing disk by attaching it during creation process), that VM doesn't have a source_image parameters set at all.
In that case source_image_reference is null and source_image_id = "" on Azure side and you have to be able to reflect that in terraform, otherwise terraform wants to re-create the whole VM.
Currently the only workaround we've found is to use some not existing, only visually proper source_image_id like the one in example configuration section ("" is not working because of parsing errors) and then add:
lifecycle {
ignore_changes = [
source_image_id
]
}
So that terraform just ignore this section and is not trying to recreate.
Actual Behaviour
Terraform errors out during parsing and doesn't want to proceed with empty source_image variables - which is incorrect given that it is allowed on Azure.
IMPORTANT: It was working correctly up to version 3.30.0, but I couldn't see any remarks about any changes within the resource in release notes after that
Steps to Reproduce
Sorry, since this is a very specific scenario, it is impossible to provide exact steps, unless we include tons of powershell/az commands to prepare the environment first.
The easiest way to reproduce is to create a vm attaching the existing disks, then import in terraform, so that following command displays the same as below:
tf state show MODULE.azurerm_windows_virtual_machine.main | grep image
and then create a base code for the VM and try to perform terraform plan WITHOUT any source_image_xxxxxx variables present in the code.
With <= 3.30 it will work, with 3.31 it will fail on dependencies.
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: