Is there an existing issue for this?
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.
Description
The azurerm_virtual_machine_power action currently supports only three settings: power_off, power_on, and restart. If power_off is selected, the machine is simply stopped but not deallocated. Therefore the machine instance will still being charged.
Please add an additional power action to deallocate.
New or Affected Resource(s)/Data Source(s)
azurerm_virtual_machine_power
Potential Terraform Configuration
# Supposed new action: deallocate
action "azurerm_virtual_machine_power" "deallocate" {
config {
virtual_machine_id = azurerm_linux_virtual_machine.example.id
power_action = "deallocate"
}
}
terraform apply -invoke=action.azurerm_virtual_machine_power.deallocate --auto-approve
# Result
[
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"time": "2026-03-21T09:00:19.7356741+00:00"
},
{
"code": "PowerState/deallocated",
"displayStatus": "VM deallocated",
"level": "Info"
}
]
...
# Current working action with power_off
action "azurerm_virtual_machine_power" "off" {
config {
virtual_machine_id = azurerm_linux_virtual_machine.example.id
power_action = "power_off"
}
}
terraform apply -invoke=action.azurerm_virtual_machine_power.off --auto-approve
az vm get-instance-view \
--name "$(terraform output -raw vm_name)" \
--resource-group "$(terraform output -raw rg_name)" \
-o json | jq '.instanceView.statuses'
[
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"time": "2026-03-21T06:39:16.7527524+00:00"
},
{
"code": "PowerState/stopped",
"displayStatus": "VM stopped",
"level": "Info"
}
]
References
References
https://learn.microsoft.com/en-us/azure/virtual-machines/states-billing
Is there an existing issue for this?
Community Note
Description
The
azurerm_virtual_machine_poweraction currently supports only three settings:power_off,power_on, andrestart. Ifpower_offis selected, the machine is simply stopped but not deallocated. Therefore the machine instance will still being charged.Please add an additional power action to deallocate.
New or Affected Resource(s)/Data Source(s)
azurerm_virtual_machine_power
Potential Terraform Configuration
References
References
https://learn.microsoft.com/en-us/azure/virtual-machines/states-billing