Skip to main content
Providers

ComputeInstance

A resource of the GCP provider, version 0.2.0, in its Compute group. Import it with:

import ComputeInstance from "gcp/compute"

Example

resource ComputeInstance example {
    name             = "example-value"
    machineType      = "example-value"
    zone             = "example-value"
    imageFamily      = "example-value"
    imageProject     = "example-value"
    networkInterface = "example-value"
    subnetwork       = "example-value"
    tags             = "..."
    labels           = "..."
    diskSizeGb       = 3.14
    diskType         = "pd-standard"
    externalIp       = true
    startupScript    = "example-value"
    serviceAccount   = "example-value"
    scopes           = "..."
    preemptible      = false
}

Properties

Set by your code in the resource block. A required one must be set; any other you leave out takes the value under Default, if it has one.

NameTypeDefaultRequiredDescription
namestring—NoThe name of the instance
machineTypestring—NoThe machine type (e.g., e2-medium, n1-standard-1)
zonestring—NoThe zone where the instance will be created (e.g., us-central1-a)
imageFamilystring—NoThe image family to use for the boot disk (e.g., debian-12)
imageProjectstring—NoThe project containing the image family (e.g., debian-cloud)
networkInterfacestring—NoThe VPC network name or self-link for the primary network interface
subnetworkstring—NoThe subnetwork name or self-link for the primary network interface
tagsany[]—NoNetwork tags for firewall rules
labelsobject—NoLabels to apply to the instance
diskSizeGbnumber—NoBoot disk size in GB
diskTypestring—NoBoot disk type Allowed: "pd-standard", "pd-ssd", "pd-balanced"
externalIpbooleantrueNoWhether to assign an external IP address
startupScriptstring—NoStartup script content
serviceAccountstring—NoThe service account email for the instance
scopesany[]—NoOAuth2 scopes for the service account
preemptiblebooleanfalseNoWhether to enable preemptible/spot scheduling

Set by GCP after the resource is created: your code can read them but not set them. An importable one identifies an existing resource.

NameTypeImportableDescription
instanceIdstringYesThe unique instance ID assigned by GCP
statusstringNoThe instance status (PROVISIONING, STAGING, RUNNING, STOPPING, STOPPED, TERMINATED)
selfLinkstringNoThe self-link URL of the instance
externalIpAddressstringNoThe external (public) IP address
internalIpAddressstringNoThe internal (private) IP address

On this page