Alibaba Cloud ECS Metadata, User Data, and Dynamic Data

By Anish Nath, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Alibaba Cloud Elastic Compute Service (ECS) instance metadata provides data about your instance that you can use to configure or manage the running instance. Instance metadata is divided into several categories.

Before You Begin

Make sure you have a valid Alibaba Cloud account to try out this experiment. You’ll also need an Alibaba Cloud ECS instance to follow this tutorial.


  1. The metadata is only applicable for VPC-Connected instances.
  2. Any Manual change in the instance information will not reflect in the instance metadata.
  3. Metadata can only be accessed http GET method.

Alibaba Cloud ECS Metadata

ECS Metadata URL

ECS Instances access the metadata service at .

To retrieve a list of supported versions for the ECS metadata API, make a GET request to the following URI

At present only one version of metadata service is available i.e 2016–01–01, if the new version is added in the Alibaba Metadata service then you will be noticing more new version folder.

windows users can use PowerShell cmdlets to retrieve the URI. For example, if you are running version 3.0 or later of PowerShell, use the following cmdlet:

To view latest version of all available service use the below command.

Retrieve Latest Metadata

To view all latest categories of instance metadata from within a running instance, use the following URI:

The above example gets the top-level metadata items of the running ECS instance. For more information about each of these items refer Alibaba Docs.

Retrieve ECS hostname

This example shows the my ECS instance hostname is webserver-01

Retrieve public EIP of the ECS Instance

EIP are logically associated with the instance and it will not show up in the interface, in order to retrieve the EIP use the following URI

Retrieve Private IP of the ECS instance

Retrieve NTP servers of the ECS Instance

Retrieve Gateway information the ECS Instance

Retrieve Primary IP address the ECS Instance

If the ECS is having multiple IP’s this query will be useful to determine the primary ip address of the ECS instance.

Retrieve DNS server information of the ECS Instance

Retrieve Region Information

Retrieve ECS instance Type

This example shows the my ECS instance is using ecs.t5-lc2m1.nano flavor.

Retrieve Latest User Data

Alibaba Cloud instance metadata can be used to access user data that you specified when launching your ECS instance.

Retrieving Dynamic Data

To retrieve dynamic data from within a running instance, use the following URI:

The instance-identity document is generated when the ECS instance is launched,

Retrieve instance-identity signature (PKCS7), use the following URI

Verify the instance-id

The instance-identity can be verified by using the OpenSSL commands, for this you will be needing the public certificate of Alibaba cloud.

The public cert.cer file

The Instance-identity verification process.

This verification process guarantees that this ECS instances are running on the Alibaba cloud environment.


In this example, we are going to troubleshoot 404 Not found error resulted during the http get request on accessing public-keys metadata.

This error means that this property was not set during the ECS launch.

To fix these Issues first query whether the desired property public-keys is available on the ECS instance or not by looking up the root directory structure, use the following URI to know

As shown the above output the public-keys metadata information is not available. I need to add this information on the ECS instance.

What I did is, I stopped the instance and bind my SSH public key to this ECS instance id and then restarted the instance to get metadata updated. After the restart the public-keys metadata information is available.

So now if I want to retrieve my SSH public key information, I can query