-
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
virtual_machine: Setting ultra_ssd_enabled from implicit default to explicit default value false does not work #8606
Comments
I tried adding a DiffSuppressFunc for --- a/azurerm/internal/services/compute/virtual_machine.go
+++ b/azurerm/internal/services/compute/virtual_machine.go
@@ -29,6 +29,13 @@ func virtualMachineAdditionalCapabilitiesSchema() *schema.Schema {
Type: schema.TypeBool,
Optional: true,
Default: false,
+ DiffSuppressFunc: func(_, old, new string, _ *schema.ResourceData) bool {
+ if old == "false" && new == "" || old == "" && new == "false" {
+ return true
+ }
+
+ return false
+ },
},
},
}, This does not work because it only applies to the
And this ends in a Terraform crash. Our use case for adding Is there a way to tell Terraform that it should ignore empty blocks? Or has anyone an idea how to get this fixed? |
In addition to the problem described, if you set it to null, it still takes action as well, when it shouldn't. For example, if someone creates a module with an input variable for setting
If it isn't specified I would expect it to not be added to the request. |
Thanks for opening this issue. This was a problem in the 2.x version of the provider which is no longer actively maintained. |
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. |
Community Note
Terraform (and AzureRM Provider) Version
Terraform v0.12.29 (also tried with Terraform v0.13.3)
terraform-provider-azurerm_v2.28.0_x5
Affected Resource(s)
azurerm_linux_virtual_machine
azurerm_windows_virtual_machine
Terraform Configuration Files
Expected Behavior
If you add
additional_capabilities
block withultra_ssd_enabled = false
to the above shown HCL, Terraform should do nothing. In the Azure APIfalse
is the default, so if you did not specify the attribute before it is the same as setting it now tofalse
.Actual Behavior
Terraform thinks there is a change to
additional_capabilities
andultra_ssd_enabled
and tries updating:But it fails with following error message:
OperationNotAllowed" Message="'additionalCapabilities.ultraSSDEnabled' can be updated only when VM is in deallocated state.
In normal scenarios (Updating
ultra_ssd_enabled
from no value totrue
or fromtrue
tofalse
) Terraform recognizes that a deallocation is needed and deallocates the VM.I think the failure is caused because Azure API does not return the default value
false
if you did not explicitly specified it. So Terraform thinks there is change:""
->false
Steps to Reproduce
terraform apply
the above described HCLterraform plan
/terraform apply
Important Factoids
Could be similar issue as for
license_type
inazurerm_windows_virtual_machine
. There it was solved using DiffSuppressFunc (see #8542), but I did not get it working for this issue.The text was updated successfully, but these errors were encountered: