terraform-provider-azurerm: Previously applied configs for "azurerm_mssql_virtual_machine" fails if the virtual machine is not in Running state
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 “+1” or “me too” comments, 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
Terraform (and AzureRM Provider) Version
Terraform v0.12.24 Terraform Provider Azurerm: 2.7.0
Affected Resource(s)
azurerm_mssql_virtual_machine
Terraform Configuration Files
resource "azurerm_mssql_virtual_machine" "vm_sql" {
count = "1"
virtual_machine_id = element(azurerm_virtual_machine.vm_db.*.id,count.index)
sql_license_type = "PAYG"
auto_patching {
day_of_week = "Sunday"
maintenance_window_duration_in_minutes = 180
maintenance_window_starting_hour = 2
}
Debug Output
Panic Output
Error: reading Sql Virtual Machine (Sql Virtual Machine Name “vmname” / Resource Group “rgname”): sqlvirtualmachine.SQLVirtualMachinesClient#Get: Failure responding to request: StatusCode=400 – Original Error: autorest/azure: Service returned an error. Status=400 Code=“VmNotRunning” Message=“The VM: /subscriptions/xxxx-xxxx-xxxx-xxxx-xxxxx/resourceGroups/rgname/providers/Microsoft.Compute/virtualMachines/vmname is not in running state.” The action Terraform Plan failed
Expected Behavior
VM should be skipped if it’s not in the Running state. Or it would be great to have some parameters to enable/disable the “skip” option.
Actual Behavior
Terraform plan/apply failed if VM is not in the Running state.
Steps to Reproduce
terraform plan
Important Factoids
References
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 4
- Comments: 17 (7 by maintainers)
Any update on this one? It’s really annoying to have the VM started up just so my TF plan can complete…
This confirms that a workaround i needed in the terraform provider
Could be, but it’s only an issue for
azurerm_mssql_virtual_machine, not for regular VM. It’s a bit weird that they would work differently.I am experiencing this issue as well. I have three environments which are applied from 1 pipeline trough stages. Running the test stage works like a charm, but the acceptance environment is normally turned off, so every time I run the pipeline, I run into issue with the plan of acceptance env due to turned off SQL machine. Really annoying so please fix this!
@FarshadHadei check this: https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/internal/services/analysisservices/analysis_services_server_resource.go#L250-L265