In the Alibaba cloud Enviroment, how to find out the instance id of an ECS instance from within the ECS instance?
Asked
Active
Viewed 769 times
3 Answers
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
- Connect to a Linux instance by using a password.
- Run
curl http://100.100.100.200/latest/meta-data/
to access the root directory of the metadata. - 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. Runcurl http://100.100.100.200/latest/meta-data/image-id
to get the image ID of an ECS instance.
For Windows Instances
- Connect to a Windows instance.
- Use PowerShell to run
Invoke-RestMethod http://100.100.100.200/latest/meta-data/
to get the metadata. - 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. RunInvoke-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

Ranjith Udayakumar
- 99
- 2
- 2
- 8