The example shows how to create an ECS instance by calling the CreateInstance API of Alibaba Cloud Python SDK.

Elastic Compute Service (ECS) is a type of computing service that features elastic processing capabilities. ECS has a simpler and more efficient management mode than physical servers. You can create instances, change the operating system, and add or release any quantity of ECS instances at any time to fit your business needs.

To create an ECS instance, obtain the following information:

  • Image ID

    Obtain the ID of the image to use by calling the DescribeImages API.

  • Instance type

    Select the instance type to use. For more information, see Instance type families.

Code example

Notice Running the code in this example will create an ECS instance and generate fees.
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkecs.request.v20140526 import CreateInstanceRequest
# Create an AcsClient instance
client = AcsClient(

# Create a request and set parameters
request = CreateInstanceRequest.CreateInstanceRequest()
# Initiate an API request and print the response
response = client.do_action_with_exception(request)
print response