2

In the Alibaba cloud Enviroment, how to find out the instance id of an ECS instance from within the ECS instance?

anish
  • 6,884
  • 13
  • 74
  • 140

3 Answers3

2

You can run this query for Linux ECS

curl http://100.100.100.200/latest/meta-data/instance-id

For Windows ECS use PowerShell and execute the following code

Invoke-RestMethod http://100.100.100.200/latest/meta-data/instance-id

Source: https://www.alibabacloud.com/help/doc-detail/49122.htm

wojcieh
  • 312
  • 1
  • 8
1

Steps for Linux Instance

  1. Connect to a Linux instance by using a password.
  2. Run curl http://100.100.100.200/latest/meta-data/ to access the root directory of the metadata.
  3. Add the specific metadata name to the preceding command to access the specified metadata. For example: Run curl http://100.100.100.200/latest/meta-data/instance-id to get the ID of an ECS instance. Run curl http://100.100.100.200/latest/meta-data/image-id to get the image ID of an ECS instance.

For Windows Instances

  1. Connect to a Windows instance.
  2. Use PowerShell to run Invoke-RestMethod http://100.100.100.200/latest/meta-data/ to get the metadata.
  3. Add the specific metadata name to the preceding command to access the specified metadata. For example: Run Invoke-RestMethod http://100.100.100.200/latest/meta-data/instance-id to get the ID of an ECS instance. Run Invoke-RestMethod http://100.100.100.200/latest/meta-data/image-id to get the image ID of an ECS instance.
Deepak Kamat
  • 1,880
  • 4
  • 23
  • 38
0

Please ensure that you have the OpenSSL configured in your ECS instance before issuing the commands.

You can get the instance ID of Linux ECS instance by issuing the following command:

curl http://100.100.100.200/latest/meta-data/instance-id

For Windows ECS instance use Powershell:

Invoke-RestMethod http://100.100.100.200/latest/meta-data/instance-id