Alle Codebeispiele für Compute Engine

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

Check operation status

Request to wait until an operation completes and get the operation status before continuing code execution.

View in documentation

Create a firewall rule

Create a firewall rule that allows incoming HTTP and HTTPS access from the entire internet.

View in documentation

Create a VM instance

Create a VM instance in the specified project and zone.

Create a VM instance from an instance template

Use an instance template to create a VM instance in the specified project and zone.

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.

Create a VM with a custom hostname

Create a VM with a custom hostname that conforms to the RFC 1035 requirements for valid hostnames.

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 firewall rule

Delete a firewall rule from a specified project.

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.

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.

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.

List firewall rules in a project

Get a list of all firewall rules defined in your project.

View in documentation

List instance templates in a project

Get a list of instance templates defined in a project.

List VM instances in a project

List instances in a project, either in one zone or across all zones.

View in documentation

Reset a VM instance

Reset a running VM instance to its initial state.

View in documentation

Start a VM instance

Restart a stopped VM instance.

View in documentation

Start a VM with encrypted disks

Provide an encryption key and start a VM instance that has encrypted disks.

View in documentation

Stop a VM instance

Stop a running VM instance.

View in documentation

Update a firewall rule

Modify the priority of a firewall rule.

View in documentation