Displays or sets metadata for a compute instance. When run without any command line options, oci-metadata lists all available metadata.

For more information about instance metadata, see Getting Instance Metadata.


oci-metadata [-h | --human-readable] [-j | --json] [-g | --get key] [--export] [--trim] [--value-only] [-u key_value] [-i | --instance-id OCID] [--help]


-h | --human-readable

Display human readable output (default).

-j | --json

Display output in JSON.

-g key | --get key

Retrieve data only for the specified key.


Used with the -g or --get option, display a shell command to export the key as an environment variable.


Used with the -g or --get option, trim the key path to the last component to make the output more concise; for example, instance/metadata/ssh_authorized_keys to ssh_authorized_keys. If the key matches multiple keys, only the first matching key is displayed.


Used with the -g or --get option, display only the values matching the get key.

-u key_value

Update the value for the given key (or keys). For key_value, specify a string, a JSON value, or a pointer to a file with JSON content in the following format: key=file:/path/to/file

-i | --instance-id OCID

Get or update the metadata of the instance with the given OCID. By default, oci-metadata works with the metadata from the instance that you logged in to.


Display a summary of the command line options.


Getting all metadata for the instance

Running oci-metadata with no options returns all metadata for the instance:

$ oci-metadata
Instance details:
  Display Name: my-example-instance
  Region: phx - us-phoenix-1 (Phoenix, AZ, USA)
  Canonical Region Name: us-phoenix-1
  Availability Domain: cumS:PHX-AD-1
  Fault domain: FAULT-DOMAIN-3
  OCID: ocid1.instance.oc1.phx.exampleuniqueID
  Compartment OCID: ocid.compartment.oc1..exampleuniqueID
  Instance shape: VM.Standard2.1
  Image ID: ocid1.image.oc1.phx.exampleuniqueID
  Created at: 1569529065596
  state: Running
    managementDisabled: False
    monitoringDisabled: False
  Instance Metadata:
    ssh_authorized_keys: example-key
Networking details:
  VNIC OCID: ocid1.vnic.oc1.phx.exampleuniqueID
  VLAN Tag: 2392
  Private IP address:
  MAC address: 02:00:17:03:D8:FE
  Subnet CIDR block:
  Virtual router IP address:

Getting only specific metadata

The following example shows how to retrieve metadata for a specified key by using the --get parameter:

# oci-metadata --get state
Instance details:
Instance state: Running