This page contains code samples for Compute Engine. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.
Change the deletion protection setting for an existing VM
Enable deletion protection for an existing VM without stopping the VM.
View in documentation
Create a VM instance
Create a VM instance in the specified project and zone.
View in documentation
Create a VM instance from an instance template
Use an instance template to create a VM instance in the specified project and zone.
View in documentation
Create a VM instance from an instance template with overrides
Create a VM instance from an instance template, then override the disk and machine type options in the template.
View in documentation
Create a VM with a custom hostname
Create a VM with a custom hostname that conforms to the RFC 1035 requirements for valid hostnames.
View in documentation
Create a Windows Server image
Create a Windows Server image from the specified source disk.
View in documentation
Create an instance template
Use the specified machine type, boot disk and network to create an instance template.
View in documentation
Create an instance template based on an existing instance
Use the configuration of an existing VM to create an instance template.
View in documentation
Create an instance template with a subnet
Create an instance template that uses a specified subnetwork.
View in documentation
Delete a VM instance
Delete an instance based on the project, zone, and instance name that you provide.
View in documentation
Delete an instance template
Delete an instance template from a specified project.
View in documentation
Enable deletion protection for a new VM
Create a VM in the specified project and zone with deletion protection enabled.
View in documentation
Get information about an instance template
Get the basic information and instance configuration defined in an instance template.
View in documentation
Get the deletion protection status of a VM
Determine whether deletion protection is enabled for a specified VM.
View in documentation
List all non-deprecated images in a project
Get a list of all non-deprecated images available in a specified project.
View in documentation
List instance templates in a project
Get a list of instance templates defined in a project.
View in documentation