GoogleComputeInstance class final

Factory wrapper for google_compute_instance.

An instance is a virtual machine (VM) hosted on Google's infrastructure.

Required identity:

  • localName: Terraform local name (the address segment after google_compute_instance.).
  • name: GCE instance name. Forces replacement when changed.
  • machineType: short machine type name (e.g. 'e2-medium') or full self-link of a custom machine type.
  • bootDisk: a ComputeInstanceBootDisk describing the boot volume; the wrapper converts this to the single-element boot_disk block GCP expects.
  • networkInterface: at least one ComputeInstanceNetworkInterface entry. GCP requires every VM to attach to a VPC.

Example (minimal):

final vm = GoogleComputeInstance(
  localName: 'web',
  name: TfArg.literal('web-01'),
  machineType: TfArg.literal('e2-medium'),
  zone: TfArg.literal('us-central1-a'),
  bootDisk: const ComputeInstanceBootDisk(
    initializeParams: ComputeInstanceInitializeParams(
      image: 'debian-cloud/debian-12',
    ),
  ),
  networkInterface: const [
    ComputeInstanceNetworkInterface(
      network: 'default',
      accessConfig: [ComputeInstanceAccessConfig()],
    ),
  ],
);

The 12 nested blocks (boot_disk / network_interface / attached_disk / scratch_disk / service_account / scheduling / shielded_instance_config / confidential_instance_config / guest_accelerator / advanced_machine_features / reservation_affinity / params / network_performance_config) are modeled as helper classes in the prelude below. Single-instance blocks (max_items=1) are wrapped in a [map] list before being passed to Terraform; list-typed blocks are passed through as List<Map>.

Constructors

GoogleComputeInstance({required String localName, required TfArg<String> name, required TfArg<String> machineType, TfArg<String>? zone, TfArg<String>? description, TfArg<String>? hostname, TfArg<Map<String, String>>? labels, TfArg<List<String>>? tags, TfArg<Map<String, String>>? metadata, TfArg<String>? metadataStartupScript, TfArg<bool>? canIpForward, TfArg<bool>? deletionProtection, TfArg<bool>? allowStoppingForUpdate, TfArg<String>? desiredStatus, TfArg<String>? minCpuPlatform, TfArg<bool>? enableDisplay, TfArg<List<String>>? resourcePolicies, TfArg<String>? keyRevocationActionType, required ComputeInstanceBootDisk bootDisk, required List<ComputeInstanceNetworkInterface> networkInterface, List<ComputeInstanceAttachedDisk>? attachedDisk, List<ComputeInstanceScratchDisk>? scratchDisk, ComputeInstanceServiceAccount? serviceAccount, ComputeInstanceScheduling? scheduling, ComputeInstanceShieldedInstanceConfig? shieldedInstanceConfig, ComputeInstanceConfidentialInstanceConfig? confidentialInstanceConfig, List<ComputeInstanceGuestAccelerator>? guestAccelerator, ComputeInstanceAdvancedMachineFeatures? advancedMachineFeatures, ComputeInstanceReservationAffinity? reservationAffinity, ComputeInstanceInstanceParams? params, ComputeInstanceNetworkPerformanceConfig? networkPerformanceConfig, TfArg<String>? project, LifecycleOptions? lifecycle, List<DependencyTarget>? dependsOn})

Properties

argMap Map<String, TfArg?>
Argument-name → TfArg map. Keys are snake_case (Terraform JSON name). Synth emits these keys directly; the factory is responsible for the camelCase → snake_case translation at construction time.
finalinherited
cpuPlatform → TfRef<String>
Reference to cpu_platform attribute.
no setter
creationTimestamp → TfRef<String>
Reference to creation_timestamp attribute.
no setter
currentStatus → TfRef<String>
Reference to current_status attribute.
no setter
dependsOn List<DependencyTarget>?
Optional depends_on = [...]. Each entry is a DependencyTarget — either a wholesale resource (rendered as bare address) or an explicit TfRef (rendered via bareAddress).
finalinherited
effectiveLabels → TfRef<Map<String, String>>
Reference to effective_labels attribute.
no setter
hashCode int
The hash code for this object.
no setterinherited
id → TfRef<String>
Reference to id attribute (full path projects/{project}/zones/{zone}/instances/{name}).
no setter
instanceId → TfRef<String>
Reference to instance_id attribute.
no setter
kind → ResourceKind
Always ResourceKind.resource. Overridden by Data.
no setterinherited
labelFingerprint → TfRef<String>
Reference to label_fingerprint attribute.
no setter
lifecycle → LifecycleOptions?
Optional lifecycle { ... } block.
finalinherited
localName String
User-supplied local name within a Stack.
finalinherited
metadataFingerprint → TfRef<String>
Reference to metadata_fingerprint attribute.
no setter
nameRef → TfRef<String>
Reference to name attribute. Use for interpolations like vm.nameRef -> ${google_compute_instance.<localName>.name}.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
Reference to self_link attribute.
no setter
sensitiveFields Set<String>
Field names that are @Sensitive per the IR-derived per-resource constant. Curated factories override with a baked-in static const Set<String> (file-private in v0.5+).
no setter
supportsDeletionProtection bool
Capability flag: true when this resource's underlying Terraform schema has a deletion_protection boolean attribute that the synth-time devMode flow can flip to false. Defaults to false; the codegen emitter overrides this to true for wrappers whose schema includes the attribute.
no setter
tagsFingerprint → TfRef<String>
Reference to tags_fingerprint attribute.
no setter
terraformLabels → TfRef<Map<String, String>>
Reference to terraform_labels attribute.
no setter
terraformType String
Terraform resource type, e.g. google_pubsub_topic.
finalinherited
tfAddress String
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

tfType → const String