» google_compute_instance

Get information about a VM instance resource within GCE. For more information see the official documentation and API.

» Example Usage

data "google_compute_instance" "appserver" {
  name = "primary-application-server"
  zone = "us-central1-a"
}

» Argument Reference

The following arguments are supported:

  • self_link - (Optional) The self link of the instance. One of name or self_link must be provided.

  • name - (Optional) The name of the instance. One of name or self_link must be provided.


  • project - (Optional) The ID of the project in which the resource belongs. If self_link is provided, this value is ignored. If neither self_link nor project are provided, the provider project is used.

  • zone - (Optional) The zone of the instance. If self_link is provided, this value is ignored. If neither self_link nor zone are provided, the provider zone is used.

» Attributes Reference


The boot_disk block supports:

  • auto_delete - Whether the disk will be auto-deleted when the instance is deleted.

  • device_name - Name with which attached disk will be accessible under /dev/disk/by-id/

  • initialize_params - Parameters with which a disk was created alongside the instance. Structure is documented below.

  • source - The name or self_link of an existing disk (such as those managed by google_compute_disk) that was attached to the instance.

The initialize_params block supports:

  • size - The size of the image in gigabytes.

  • type - The GCE disk type. One of pd-standard or pd-ssd.

  • image - The image from which this disk was initialised.

The scratch_disk block supports:

  • interface - The disk interface used for attaching this disk. One of SCSI or NVME.

The attached_disk block supports:

  • source - The name or self_link of the disk attached to this instance.

  • device_name - Name with which the attached disk is accessible under /dev/disk/by-id/

  • mode - Read/write mode for the disk. One of "READ_ONLY" or "READ_WRITE".

The network_interface block supports:

  • network - The name or self_link of the network attached to this interface.

  • subnetwork - The name or self_link of the subnetwork attached to this interface.

  • subnetwork_project - The project in which the subnetwork belongs.

  • network_ip - The private IP address assigned to the instance.

  • access_config - Access configurations, i.e. IPs via which this instance can be accessed via the Internet. Structure documented below.

  • alias_ip_range - An array of alias IP ranges for this network interface. Structure documented below.

The access_config block supports:

The alias_ip_range block supports:

  • ip_cidr_range - The IP CIDR range represented by this alias IP range.

  • subnetwork_range_name - The subnetwork secondary range name specifying the secondary range from which to allocate the IP CIDR range for this alias IP range.

The service_account block supports:

  • email - The service account e-mail address.

  • scopes - A list of service scopes.

The scheduling block supports:

  • preemptible - Whether the instance is preemptible.

  • on_host_maintenance - Describes maintenance behavior for the instance. One of MIGRATE or TERMINATE, for more info, read here

  • automatic_restart - Specifies if the instance should be restarted if it was terminated by Compute Engine (not a user).

The guest_accelerator block supports:

  • type - The accelerator type resource exposed to this instance. E.g. nvidia-tesla-k80.

  • count - The number of the guest accelerator cards exposed to this instance.

The shielded_instance_config block supports: