-
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
stopped virtual machine in terraform #555
Comments
hey @retheshnair Thanks for opening this issue. The AzureRM Terraform Provider doesn't currently support managing the State of Virtual Machines (e.g. Running/Stopped) - so that we can understand the issue better, would it be possible to get some more information about the issue you're facing? Thanks! |
@tombuildsstuff I may be seeing the same or a similar issue with stopped (deallocated) VMs in Azure and terraform. I have three machines that I keep stopped and launch programatically based on data availability in my application. If they are stopped, terraform plan reports:
When I run terraform apply (just for giggles), I get errors:
It seems like the provider should understand the machine state enough to not plan changes when managed machines are stopped. Terraform v0.10.8
|
@tombuildsstuff yep @clippermadness has put the details . Still i will try to put more details Case -1 After provisioning the machine using terraform I have stop it from portal or azcli since terrafrom don't have options of specifying the state . Something like state = deallocated or stopped . Once the VM is deallocated if we try to do terraform plan it is showing a in-place update since the disk is Reserved but not leased Case-2 We should have something like state = stopped or deallocated in azurerm_virtual_machine to manage the state from terraform
[root@puppettest RETHESH_PUPPETPREPROD]# Terraform Plan ( Deallocated )An execution plan has been generated and is shown below. Terraform will perform the following actions: ~ azurerm_virtual_machine.puppetserver_vms Plan: 0 to add, 1 to change, 0 to destroy. Note: You didn't specify an "-out" parameter to save this plan, so Terraform Terraform Apply ( Dealloacted)storage_os_disk.0.disk_size_gb: "0" => "50" Error: Error applying plan: 1 error(s) occurred:
Terraform does not automatically rollback in the face of errors. [root@puppettest RETHESH_PUPPETPREPROD]# Terraform Plan (still incurring compute charges)No changes. Infrastructure is up-to-date. This means that Terraform did not detect any differences between your
|
@tombuildsstuff . with the ARM API you can't get the VM state in the List ALL VMs API. You need to call the instance view API on each VM to get this.
This API call will fetch the
On AWS we can get the description of instances and get the status, but on Azure we need to send an individual request for every instance just to find out if they are running, deallocated or stopped. Please refer this link for more details . |
This closes #539 due to duplication. |
Hi @retheshnair , from the Azure Virtual Machine service team:
You can also confirm the behavior mentioned above in Azure portal. So I think you should not run any |
Hi @retheshnair and @clippermadness , just to let you know the code fix has been merged, and it will be published in 1.4.0. I will close the issue for now, if you meet any problems in the future, feel free to reopen it or create a new issue. Thanks. |
hey @retheshnair @clippermadness Just to let you know that v1.4.0 of the Azure Provider has been released which includes the fix for this :) Thanks! |
Good job @tombuildsstuff , great timing for my team! Now we can actually shut down servers and not worry about terraform thinking they don't exist at all! |
@tombuildsstuff Confirmed: works. Thanks! |
@tombuildsstuff I just tried to update managed OS disks on VMs that are powered down (stopped/ deallocated via portal) and they still fail. I get the same error even when they're up and running, actually. plan: error: Error: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status= Code="OperationNotAllowed" Message="Managed disk storage account type change through Virtual Machine 'infrajumpp02' is not allowed. Please update disk resource at /subscriptions/123123/resourceGroups/rg/providers/Microsoft.Compute/disks/infrajumpp02-os." Target="osDisk.managedDisk.storageAccountType" |
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. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
@JohnDelisle the Both of these new resources support (amongst other things) resizing the OS Disk, changing the Storage Type - which will stop/start the virtual machine as needed to make these changes (and should work with the VM in a stopped state). Unfortunately we have no plans to backport this to the existing Thanks! |
This issue was originally opened by @retheshnair as hashicorp/terraform#16629. It was migrated here as a result of the provider split. The original body of the issue is below.
Currently when I stop VM terraform doesn't change the state in azure
Terraform Version
Run
terraform -v
to show the version. If you are not running the latest version of Terraform, please try upgrading because your issue may have already been fixed.[root@puppettest PUPPETPREPROD]# terraform -v
Terraform v0.10.8
[root@puppettest PUPPETPREPROD]#
The text was updated successfully, but these errors were encountered: