Skip to content

Commit

Permalink
Update additional capabilities.
Browse files Browse the repository at this point in the history
Allow updating additional_capabilities.
Allow changing ultra_ssd_enabled without recreation, only deallocation.
  • Loading branch information
NilsBusche committed Aug 5, 2020
1 parent 55e02f6 commit 2aceea5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,18 @@ func resourceLinuxVirtualMachineUpdate(d *schema.ResourceData, meta interface{})
update.Tags = tags.Expand(tagsRaw)
}

if d.HasChange("additional_capabilities") {
shouldUpdate = true

if d.HasChange("additional_capabilities.0.ultra_ssd_enabled") {
shouldShutDown = true
shouldDeallocate = true
}

additionalCapabilitiesRaw := d.Get("additional_capabilities").([]interface{})
update.VirtualMachineProperties.AdditionalCapabilities = expandVirtualMachineAdditionalCapabilities(additionalCapabilitiesRaw)
}

if shouldShutDown {
log.Printf("[DEBUG] Shutting Down Linux Virtual Machine %q (Resource Group %q)..", id.Name, id.ResourceGroup)
forceShutdown := false
Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/compute/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func virtualMachineAdditionalCapabilitiesSchema() *schema.Schema {
Type: schema.TypeBool,
Optional: true,
Default: false,
ForceNew: true,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,18 @@ func resourceWindowsVirtualMachineUpdate(d *schema.ResourceData, meta interface{
update.Tags = tags.Expand(tagsRaw)
}

if d.HasChange("additional_capabilities") {
shouldUpdate = true

if d.HasChange("additional_capabilities.0.ultra_ssd_enabled") {
shouldShutDown = true
shouldDeallocate = true
}

additionalCapabilitiesRaw := d.Get("additional_capabilities").([]interface{})
update.VirtualMachineProperties.AdditionalCapabilities = expandVirtualMachineAdditionalCapabilities(additionalCapabilitiesRaw)
}

if shouldShutDown {
log.Printf("[DEBUG] Shutting Down Windows Virtual Machine %q (Resource Group %q)..", id.Name, id.ResourceGroup)
forceShutdown := false
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/linux_virtual_machine.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ The following arguments are supported:

A `additional_capabilities` block supports the following:

* `ultra_ssd_enabled` - (Optional) Should the capacity to enable Data Disks of the `UltraSSD_LRS` storage account type be supported on this Virtual Machine? Defaults to `false`. Changing this forces a new resource to be created.
* `ultra_ssd_enabled` - (Optional) Should the capacity to enable Data Disks of the `UltraSSD_LRS` storage account type be supported on this Virtual Machine? Defaults to `false`.

---

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/windows_virtual_machine.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ The following arguments are supported:

A `additional_capabilities` block supports the following:

* `ultra_ssd_enabled` - (Optional) Should the capacity to enable Data Disks of the `UltraSSD_LRS` storage account type be supported on this Virtual Machine? Defaults to `false`. Changing this forces a new resource to be created.
* `ultra_ssd_enabled` - (Optional) Should the capacity to enable Data Disks of the `UltraSSD_LRS` storage account type be supported on this Virtual Machine? Defaults to `false`.

---

Expand Down

0 comments on commit 2aceea5

Please sign in to comment.