Skip to content

googleComputeInstance

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

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.dataGoogleComputeInstance.DataGoogleComputeInstance(
  this,
  "appserver",
  {
    name: "primary-application-server",
    zone: "us-central1-a",
  }
);

Argument Reference

The following arguments are supported:

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

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


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

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

Attributes Reference

  • bootDisk - The boot disk for the instance. Structure is documented below.

  • machineType - The machine type to create.

  • networkInterface - The networks attached to the instance. Structure is documented below.

  • attachedDisk - List of disks attached to the instance. Structure is documented below.

  • canIpForward - Whether sending and receiving of packets with non-matching source or destination IPs is allowed.

  • description - A brief description of the resource.

  • deletionProtection - Whether deletion protection is enabled on this instance.

  • guestAccelerator - List of the type and count of accelerator cards attached to the instance. Structure is documented below.

  • labels - A set of key/value label pairs assigned to the instance.

  • metadata - Metadata key/value pairs made available within the instance.

  • minCpuPlatform - The minimum CPU platform specified for the VM instance.

  • scheduling - The scheduling strategy being used by the instance. Structure is documented below

  • scratchDisk - The scratch disks attached to the instance. Structure is documented below.

  • serviceAccount - The service account to attach to the instance. Structure is documented below.

  • tags - The list of tags attached to the instance.

  • instanceId - The server-assigned unique identifier of this instance.

  • metadataFingerprint - The unique fingerprint of the metadata.

  • selfLink - The URI of the created resource.

  • tagsFingerprint - The unique fingerprint of the tags.

  • labelFingerprint - The unique fingerprint of the labels.

  • cpuPlatform - The CPU platform used by this instance.

  • shieldedInstanceConfig - The shielded vm config being used by the instance. Structure is documented below.

  • enableDisplay -- Whether the instance has virtual displays enabled.

  • networkInterface0NetworkIp - The internal ip address of the instance, either manually or dynamically assigned.

  • networkInterface0AccessConfig0NatIp - If the instance has an access config, either the given external ip (in the natIp field) or the ephemeral (generated) ip (if you didn't provide one).

  • networkPerformanceConfig - The network performance configuration setting for the instance, if set. Structure is documented below.

  • attachedDisk0DiskEncryptionKeySha256 - The RFC 4648 base64 encoded SHA-256 hash of the [customer-supplied encryption key] (https://cloud.google.com/compute/docs/disks/customer-supplied-encryption) that protects this resource.

  • bootDiskDiskEncryptionKeySha256 - The RFC 4648 base64 encoded SHA-256 hash of the [customer-supplied encryption key] (https://cloud.google.com/compute/docs/disks/customer-supplied-encryption) that protects this resource.

  • disk0DiskEncryptionKeySha256 - The RFC 4648 base64 encoded SHA-256 hash of the [customer-supplied encryption key] (https://cloud.google.com/compute/docs/disks/customer-supplied-encryption) that protects this resource.


The bootDisk block supports:

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

  • deviceName - Name with which attached disk will be accessible under /dev/disk/byId/

  • initializeParams - 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 googleComputeDisk) that was attached to the instance.

The initializeParams block supports:

  • size - The size of the image in gigabytes.

  • type - The GCE disk type. One of pdStandard or pdSsd.

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

  • labels - A set of key/value label pairs assigned to the disk.

The scratchDisk block supports:

  • interface - The disk interface used for attaching this disk. One of scsi or nvme.

The attachedDisk block supports:

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

  • deviceName - Name with which the attached disk is accessible under /dev/disk/byId/

  • mode - Read/write mode for the disk. One of "readOnly" or "readWrite".

The networkInterface 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.

  • subnetworkProject - The project in which the subnetwork belongs.

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

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

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

The accessConfig block supports:

  • natIp - The IP address that is be 1:1 mapped to the instance's network ip.

  • publicPtrDomainName - The DNS domain name for the public PTR record.

  • networkTier - The networking tier used for configuring this instance. One of premium or standard.

The aliasIpRange block supports:

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

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

The serviceAccount 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.

  • onHostMaintenance - Describes maintenance behavior for the instance. One of migrate or terminate, for more info, read here

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

  • provisioningModel - Describe the type of preemptible VM.

  • instanceTerminationAction - Describe the type of termination action for spot VM. Can be stop or delete. Read more on here

The guestAccelerator block supports:

  • type - The accelerator type resource exposed to this instance. E.g. nvidiaTeslaK80.

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

The shieldedInstanceConfig block supports:

  • enableSecureBoot -- Whether secure boot is enabled for the instance.

  • enableVtpm -- Whether the instance uses vTPM.

  • enableIntegrityMonitoring -- Whether integrity monitoring is enabled for the instance.

The networkPerformanceConfig block supports:

  • totalEgressBandwidthTier - The egress bandwidth tier for the instance.