Default VM metadata values

Compute Engine defines a set of default metadata entries that provide information about your virtual machine (VM) instance or project. Default metadata is always defined and set by the server.

For information about querying metadata values, see Storing and retrieving instance metadata.

How metadata values are arranged

  • Project and instance metadata: Metadata can be assigned to both projects and VMs. Project metadata propagates to all VMs within a project, while instance metadata only applies to a single VM.

  • Directory listings: Some metadata entries are directories that contain other metadata keys. This difference is marked by a trailing slash in the metadata name. For example, attributes/ is a directory that contains other metadata keys.

Project metadata

Project metadata entries are stored under the following directory:

  • http://metadata.google.internal/computeMetadata/v1/project/
Metadata entry Description
attributes/

A directory of custom metadata values passed to the VMs in your project during startup or shutdown. These custom values can either be Google Cloud attributes or user-created metadata values.

For a list of project-level Google Cloud attributes that you can set, see Project attributes.

For more information about setting custom metadata, see Specifying custom metadata.

numeric-project-id The numeric project ID (project number) of the instance, which is not the same as the project name that is visible in the Google Cloud Console. This value is different from the project-id metadata entry value.
project-id The project ID.

Project attributes

The project attributes are stored under the following directory:

  • http://metadata.google.internal/computeMetadata/v1/project/attributes/
Metadata entry Description
disable-legacy-endpoints

Disables legacy metadata server endpoints for all VMs in your project.

Legacy endpoints are deprecated, always set disable-legacy-endpoints=TRUE.

enable-guest-attributes

Sets guest attributes for the project.

Guest attributes are custom VM instance metadata values that you can use to publish infrequent status notifications, low volume data, or low frequency data. These values are useful for indicating when startup scripts have finished or for providing other infrequent status notifications to other applications.

For more information about guest attributes, see Setting and querying guest attributes.

enable-os-inventory

Enables or disables OS inventory for the project.

Collects and stores OS details information. This includes information such as hostname, kernel version, architecture, and installed packages details.

For more information about OS inventory, see Viewing operating system details.

enable-oslogin

Enables or disables SSH key management on your project.

For more information about OS Login, see Setting up OS Login.

google-compute-default-region If set, stores the default region that is used by the project.

For more information about setting default regions, see Default region and zone.

google-compute-default-zone If set, stores the default zone that is used by the project.

For more information about setting default zones, see Default region and zone.

ssh-keys

If you are managing SSH keys using metadata, this attribute lets you configure public SSH keys that can connect to VMs in this project. If there are multiple SSH keys, each key is separated by a newline character (\n). The value of the ssh-keys attribute is a string.

Example: "user1:ssh-rsa mypublickey user1@host.com\nuser2:ssh-rsa mypublickey user2@host.com"

SSH keys managed by OS Login aren't visible in metadata.

sshKeys Deprecated: Use ssh-keys.
vmdnssetting

Enable zonal DNS and global DNS for the VMs in your project.

For more information about internal DNS names, see Configuring DNS names.

VM instance metadata

The VM metadata entries are stored under the following directory:

  • http://metadata.google.internal/computeMetadata/v1/instance/
Metadata entry Description
attributes/

A directory of custom metadata values passed to the VM during startup or shutdown. These custom values can either be Google Cloud attributes or user-created metadata values.

For a list of instance-level Google Cloud attributes that you can set, see Instance attributes

For more information about setting custom metadata, see Specifying custom metadata.

cpu-platform

CPU platform of the VM.

For information about CPU platforms, see CPU platforms.

description The free-text description of an instance that is assigned using the --description flag by using the gcloud command-line tool or the API.
disks/

A directory of disks that are attached to the VM. For each disk, the following information is available:

  • device-name
  • index
  • interface
  • mode
  • type

For more information about disks, see Storage options.

guest-attributes/

Sets guest attributes for the VM. These custom values can either be Google Cloud attributes or user-created metadata values.

For a list of instance-level Google Cloud attributes that you can set, see Instance guest attributes

For more information about guest attributes, see Setting and querying guest attributes.

hostname The hostname of the VM.
id The ID of the VM. This is a unique, numerical ID that is generated by Compute Engine. This is useful for identifying VMs if you don't use VM names.
image The operating system image used by the VM. This value has the following format: projects/IMAGE_PROJECT/global/images/IMAGE_NAME.
legacy-endpoint-access/ Stores the list of legacy endpoints. Values are 0.1 and v1beta1.
licenses/ A list of license code IDs that are used to attach the licenses to images, snapshots, and disks.
machine-type The machine type for this VM. This value has the following format: projects/PROJECT_NUM/machineTypes/MACHINE_TYPE
maintenance-event Indicates whether a maintenance event is affecting this VM. For more information, see Live migrate.
name The name of the VM.
network-interfaces/

A directory of network interfaces. For each network interface the following information is available:

  • access-configs/

    • external-ip
    • type
  • dns-servers
  • forwarded-ips/
  • gateway
  • ip
  • ip-aliases/
  • mac
  • mtu
  • network
  • subnetmask
  • target-instance-ips

For more information about network interfaces, see Multiple network interfaces overview.

preempted

A boolean value that indicates whether a VM is about to be preempted.

scheduling/

Sets the scheduling options for the VM.

Scheduling metadata values include the following:

  • on-host-maintenance: indicates whether the VM terminates or live migrates during host maintenance.
  • automatic-restart: If this value is TRUE, the VM automatically restarts after a maintenance event or crash.
  • preemptible: If this value is TRUE, the VM is preemptible. This value is set when you create a VM, and it can't be changed.

For more information about scheduling options, see Setting instance availability policies.

service-accounts/

A directory of service accounts associated with the VM. For each service account, the following information is available:

  • aliases
  • email: The email address for the service account.
  • identity: A JSON Web Token that is unique to the VM. You must include the audience parameter in your request for this VM metadata value. For example, ?audience=http://www.example.com.

    For information about how to request and verify instance identity tokens, see Verifying the identity of instances.

  • scopes: The access scopes assigned to the service account.
  • token: The OAuth2 access token that can be used to authenticate applications.

    For information about access tokens, see Authenticating applications directly with access tokens.

For more information about service accounts, see Creating and enabling service accounts for instances.

tags

Lists any network tags associated with the VM.

For more information about network tags, see Configuring network tags.

zone The zone where this VM is located. This value has the following format: projects/PROJECT_NUM/zones/ZONE

Instance attributes

Instance attributes are stored under the following directory:

  • http://metadata.google.internal/computeMetadata/v1/instance/attributes/
Metadata entry Description
enable-oslogin

Enables or disables SSH key management on your VM.

For more information about OS Login, see Setting up OS Login.

vmdnssetting

Enable zonal DNS and global DNS for the VM.

For more information about internal DNS names, see Configuring DNS names.

ssh-keys

If you are managing SSH keys using metadata, this attribute lets you configure public SSH keys that can connect to VMs in this project. If there are multiple SSH keys, each key is separated by a newline character (\n). The value of the ssh-keys attribute is a string.

Example: "user1:ssh-rsa mypublickey user1@host.com\nuser2:ssh-rsa mypublickey user2@host.com"

SSH keys managed by OS Login aren't visible in metadata.

Instance guest attributes

Instance guest attributes are stored under the following directory:

  • http://metadata.google.internal/computeMetadata/v1/instance/guest-attributes
Metadata entry Description
guestInventory/

Stores OS inventory for the VM.

Collects and stores OS details information. This includes information such as hostname, kernel version, architecture, and installed packages details.

For more information about OS inventory, see Viewing operating system details.

hostkeys/

Stores SSH host keys. Host keys can be used to identify a particular host or machine.

For information host keys, see Storing host keys by enabling guest attributes.

What's next?