|
| 1 | +--- |
| 2 | +layout: "google" |
| 3 | +page_title: "Google: google_compute_instance" |
| 4 | +sidebar_current: "docs-google-datasource-compute-instance-x" |
| 5 | +description: |- |
| 6 | + Get a VM instance within GCE. |
| 7 | +--- |
| 8 | + |
| 9 | +# google\_compute\_instance |
| 10 | + |
| 11 | +Get information about a VM instance resource within GCE. For more information see |
| 12 | +[the official documentation](https://cloud.google.com/compute/docs/instances) |
| 13 | +and |
| 14 | +[API](https://cloud.google.com/compute/docs/reference/latest/instances). |
| 15 | + |
| 16 | + |
| 17 | +## Example Usage |
| 18 | + |
| 19 | +```hcl |
| 20 | +data "google_compute_instance" "appserver" { |
| 21 | + name = "primary-application-server" |
| 22 | + zone = "us-central1-a" |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +## Argument Reference |
| 27 | + |
| 28 | +The following arguments are supported: |
| 29 | + |
| 30 | +* `self_link` - (Optional) The self link of the instance. One of `name` or `self_link` must be provided. |
| 31 | + |
| 32 | +* `name` - (Optional) The name of the instance. One of `name` or `self_link` must be provided. |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +* `project` - (Optional) The ID of the project in which the resource belongs. |
| 37 | + If `self_link` is provided, this value is ignored. If neither `self_link` |
| 38 | + nor `project` are provided, the provider project is used. |
| 39 | + |
| 40 | +* `zone` - (Optional) The zone of the instance. If `self_link` is provided, this |
| 41 | + value is ignored. If neither `self_link` nor `zone` are provided, the |
| 42 | + provider zone is used. |
| 43 | + |
| 44 | +## Attributes Reference |
| 45 | + |
| 46 | +* `boot_disk` - The boot disk for the instance. Sructure is documented below. |
| 47 | + |
| 48 | +* `machine_type` - The machine type to create. |
| 49 | + |
| 50 | +* `network_interface` - The networks attached to the instance. Structure is documented below. |
| 51 | + |
| 52 | +* `attached_disk` - List of disks attached to the instance. Structure is documented below. |
| 53 | + |
| 54 | +* `can_ip_forward` - Whether sending and receiving of packets with non-matching source or destination IPs is allowed. |
| 55 | + |
| 56 | +* `description` - A brief description of the resource. |
| 57 | + |
| 58 | +* `deletion_protection` - Whether deletion protection is enabled on this instance. |
| 59 | + |
| 60 | +* `guest_accelerator` - List of the type and count of accelerator cards attached to the instance. Structure is documented below. |
| 61 | + |
| 62 | +* `labels` - A set of key/value label pairs assigned to the instance. |
| 63 | + |
| 64 | +* `metadata` - Metadata key/value pairs made available within the instance. |
| 65 | + |
| 66 | +* `min_cpu_platform` - The minimum CPU platform specified for the VM instance. |
| 67 | + |
| 68 | +* `scheduling` - The scheduling strategy being used by the instance. |
| 69 | + |
| 70 | +* `scratch_disk` - The scratch disks attached to the instance. Structure is documented below. |
| 71 | + |
| 72 | +* `service_account` - The service account to attach to the instance. Structure is documented below. |
| 73 | + |
| 74 | +* `tags` - The list of tags attached to the instance. |
| 75 | + |
| 76 | +* `instance_id` - The server-assigned unique identifier of this instance. |
| 77 | + |
| 78 | +* `metadata_fingerprint` - The unique fingerprint of the metadata. |
| 79 | + |
| 80 | +* `self_link` - The URI of the created resource. |
| 81 | + |
| 82 | +* `tags_fingerprint` - The unique fingerprint of the tags. |
| 83 | + |
| 84 | +* `label_fingerprint` - The unique fingerprint of the labels. |
| 85 | + |
| 86 | +* `cpu_platform` - The CPU platform used by this instance. |
| 87 | + |
| 88 | +* `network_interface.0.address` - The internal ip address of the instance, either manually or dynamically assigned. |
| 89 | + |
| 90 | +* `network_interface.0.access_config.0.assigned_nat_ip` - If the instance has an access config, either the given external ip (in the `nat_ip` field) or the ephemeral (generated) ip (if you didn't provide one). |
| 91 | + |
| 92 | +* `attached_disk.0.disk_encryption_key_sha256` - The [RFC 4648 base64](https://tools.ietf.org/html/rfc4648#section-4) |
| 93 | + encoded SHA-256 hash of the [customer-supplied encryption key] |
| 94 | + (https://cloud.google.com/compute/docs/disks/customer-supplied-encryption) that protects this resource. |
| 95 | + |
| 96 | +* `boot_disk.disk_encryption_key_sha256` - The [RFC 4648 base64](https://tools.ietf.org/html/rfc4648#section-4) |
| 97 | + encoded SHA-256 hash of the [customer-supplied encryption key] |
| 98 | + (https://cloud.google.com/compute/docs/disks/customer-supplied-encryption) that protects this resource. |
| 99 | + |
| 100 | +* `disk.0.disk_encryption_key_sha256` - The [RFC 4648 base64](https://tools.ietf.org/html/rfc4648#section-4) |
| 101 | + encoded SHA-256 hash of the [customer-supplied encryption key] |
| 102 | + (https://cloud.google.com/compute/docs/disks/customer-supplied-encryption) that protects this resource. |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +The `boot_disk` block supports: |
| 107 | + |
| 108 | +* `auto_delete` - Whether the disk will be auto-deleted when the instance is deleted. |
| 109 | + |
| 110 | +* `device_name` - Name with which attached disk will be accessible under `/dev/disk/by-id/` |
| 111 | + |
| 112 | +* `initialize_params` - Parameters with which a disk was created alongside the instance. |
| 113 | + Structure is documented below. |
| 114 | + |
| 115 | +* `source` - The name or self_link of an existing disk (such as those managed by |
| 116 | + `google_compute_disk`) that was attached to the instance. |
| 117 | + |
| 118 | +The `initialize_params` block supports: |
| 119 | + |
| 120 | +* `size` - The size of the image in gigabytes. |
| 121 | + |
| 122 | +* `type` - The GCE disk type. One of `pd-standard` or `pd-ssd`. |
| 123 | + |
| 124 | +* `image` - The image from which this disk was initialised. |
| 125 | + |
| 126 | +The `scratch_disk` block supports: |
| 127 | + |
| 128 | +* `interface` - The disk interface used for attaching this disk. One of `SCSI` or `NVME`. |
| 129 | + |
| 130 | +The `attached_disk` block supports: |
| 131 | + |
| 132 | +* `source` - The name or self_link of the disk attached to this instance. |
| 133 | + |
| 134 | +* `device_name` - Name with which the attached disk is accessible |
| 135 | + under `/dev/disk/by-id/` |
| 136 | + |
| 137 | +* `mode` - Read/write mode for the disk. One of `"READ_ONLY"` or `"READ_WRITE"`. |
| 138 | + |
| 139 | +The `network_interface` block supports: |
| 140 | + |
| 141 | +* `network` - The name or self_link of the network attached to this interface. |
| 142 | + |
| 143 | +* `subnetwork` - The name or self_link of the subnetwork attached to this interface. |
| 144 | + |
| 145 | +* `subnetwork_project` - The project in which the subnetwork belongs. |
| 146 | + |
| 147 | +* `address` - The private IP address assigned to the instance. |
| 148 | + |
| 149 | +* `access_config` - Access configurations, i.e. IPs via which this |
| 150 | + instance can be accessed via the Internet. Structure documented below. |
| 151 | + |
| 152 | +* `alias_ip_range` - An array of alias IP ranges for this network interface. Structure documented below. |
| 153 | + |
| 154 | +The `access_config` block supports: |
| 155 | + |
| 156 | +* `nat_ip` - The IP address that is be 1:1 mapped to the instance's |
| 157 | + network ip. |
| 158 | + |
| 159 | +* `public_ptr_domain_name` - The DNS domain name for the public PTR record. |
| 160 | + |
| 161 | +* `network_tier` - The [networking tier][network-tier] used for configuring this instance. One of `PREMIUM` or `STANDARD`. |
| 162 | + |
| 163 | +The `alias_ip_range` block supports: |
| 164 | + |
| 165 | +* `ip_cidr_range` - The IP CIDR range represented by this alias IP range. |
| 166 | + |
| 167 | +* `subnetwork_range_name` - The subnetwork secondary range name specifying |
| 168 | + the secondary range from which to allocate the IP CIDR range for this alias IP |
| 169 | + range. |
| 170 | + |
| 171 | +The `service_account` block supports: |
| 172 | + |
| 173 | +* `email` - The service account e-mail address. |
| 174 | + |
| 175 | +* `scopes` - A list of service scopes. |
| 176 | + |
| 177 | +The `scheduling` block supports: |
| 178 | + |
| 179 | +* `preemptible` - Whether the instance is preemptible. |
| 180 | + |
| 181 | +* `on_host_maintenance` - Describes maintenance behavior for the |
| 182 | + instance. One of `MIGRATE` or `TERMINATE`, for more info, read |
| 183 | + [here](https://cloud.google.com/compute/docs/instances/setting-instance-scheduling-options) |
| 184 | + |
| 185 | +* `automatic_restart` - Specifies if the instance should be |
| 186 | + restarted if it was terminated by Compute Engine (not a user). |
| 187 | + |
| 188 | +The `guest_accelerator` block supports: |
| 189 | + |
| 190 | +* `type` - The accelerator type resource exposed to this instance. E.g. `nvidia-tesla-k80`. |
| 191 | + |
| 192 | +* `count` - The number of the guest accelerator cards exposed to this instance. |
| 193 | + |
| 194 | +[network-tier]: https://cloud.google.com/network-tiers/docs/overview |
0 commit comments