This topic describes how to use the Alibaba Cloud SDK for Python to call the CreateScalingGroup API of Auto Scaling to create a scaling group. This topic also describes how to use the IoOptimized parameter to specify the I/O optimized instance.

Auto Scaling is a service that dynamically scales computing resources based your business trends. It enables you to dynamically adjust computing resources to meet the workload demand.

Sample code: Create an auto scaling group

Notice Make sure that you have activated the Auto Scaling service.
import json

from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkess.request.v20140828 import CreateScalingGroupRequest
from aliyunsdkess.request.v20140828 import CreateScalingConfigurationRequest

# Create an AcsClient object.
client = AcsClient(
   "<your-access-key-id>",
   "<your-access-key-secret>",
   "<your-region-id>"
);

# Create a scaling group.
request = CreateScalingGroupRequest.CreateScalingGroupRequest()
request.set_MaxSize(10)
request.set_MinSize(2)
response = client.do_action_with_exception(request)
scaling_group_id = json.loads(response)['ScalingGroupId']
print "ScalingGroupId is", scaling_group_id

# Create a scaling configuration.
request = CreateScalingConfigurationRequest.CreateScalingConfigurationRequest()
request.set_ScalingGroupId(scaling_group_id)

# Obtain ImageId by calling the DescribeImages API of ECS.
request.set_ImageId('centos_7_04_64_20G_alibase_201701015.vhd')
request.set_InstanceType('ecs.t1.xsmall')

# Obtain SecurityGroupId by calling the DescribeSecurityGroups API of ECS.
request.set_SecurityGroupId('sg-bp14z29vpgy2t****')
response = client.do_action_with_exception(request)
print response

Sample code: Specify an I/O optimized instance

# Create a scaling configuration.
request = CreateScalingConfigurationRequest.CreateScalingConfigurationRequest()
request.set_ScalingGroupId(scaling_group_id)

# Obtain ImageId by calling the DescribeImages API of ECS.
request.set_ImageId('centos_7_04_64_20G_alibase_201701015.vhd')
request.set_InstanceType('ecs.t1.xsmall')
request.set_IoOptimized('optimized')

# Obtain SecurityGroupId by calling the DescribeSecurityGroups API of ECS.
request.set_SecurityGroupId('sg-bp14z29vpgy2t****')
response = client.do_action_with_exception(request)
print response