Retrieving Instance Metadata from Within the Instance
On Compute Cloud@Customer, the Instance Metadata Service (IMDS) serves
information about a running instance to users who are logged in to that instance. IMDS also
provides information to cloud-init that you can use for various system initialization
tasks.
Note
To access IMDS metadata, use an instance image that's provided by Oracle.
The IMDS metadata includes instance information such as the following:
The SSH public key that enables users to log in to the instance
Instance attached VNICs, VNIC IDs
Instance CIDR blocks
In general, the IMDS instance metadata includes the following information:
The same information that you see on the details page of an instance in the Compute Cloud@Customer Console and in the output of the instance
get CLI.
Custom information that you add to an instance by using the
--metadata, --extended-metadata,
--ssh-authorized-keys-file, and
--user-data-file options of the instance
launch command. This metadata can't be updated after
instance launch. For a user logged into the instance, the instance metadata is
read-only.
Upgrading to IMDS Version 2 Endpoints
The Instance Metadata Service is available in two versions: version 1 and version
2.
Important
To increase the security of metadata requests, upgrade all applications to use
the IMDS version 2 endpoints, if supported by the image. Then disable use of
IMDS version 1 endpoints.
IMDS version 2 endpoints (IMDSv2) are supported on the Oracle Linux images listed in Guest Operating Systems. Other platform images and
most other images don't support IMDSv2.
For each instance, perform the following steps to upgrade to IMDSv2:
Identify applications that are making IMDSv1 requests.
For example, cloud-init makes requests to
/v# instance endpoints.
Migrate the identified applications to support IMDSv2 endpoints.
When you use /v2 endpoints, you must include the
"Authorization: Bearer Oracle" header. See the examples in Retrieving IMDS Instance Metadata.
On the details page of an instance, under Instance Details, check the
value of Legacy Instance Metadata Service Endpoints. If the value of
Legacy Instance Metadata Service Endpoints is Enabled, click Edit on
the Controls menu, and check the box for Legacy Instance Metadata
Service Endpoints Disabled.
In the output from instance list or instance
get, under instance-options, check the
value of are-legacy-imds-endpoints-disabled. If the
value of are-legacy-imds-endpoints-disabled is
null or false, use the
instance update command to specify the
following option:
Future requests to legacy (v1) endpoints will be rejected
with a 404 not found error.
Retrieving IMDS Instance Metadata 🔗
To retrieve the IMDS instance metadata, follow these steps:
Log in to the instance.
Use a cURL command to retrieve the metadata information from the HTTP
endpoint.
Information is provided through an HTTP endpoint that listens on
169.254.169.254. If an instance has multiple VNICs, you must send the
request using the primary VNIC.
Use the instance command to retrieve the instance metadata.
Use the vnics command to retrieve the VNIC data.
If you are using /v2 endpoints, as shown in the following
examples, then you must include the "Authorization: Bearer Oracle"
header.
You can view all the data for one of multiple VNICs by specifying the array
index for that VNIC data, or you can retrieve a single value for that
specified VNIC: