in ess-20220222/alibabacloud_ess20220222/client.py [0:0]
def create_scaling_group_with_options(self, request, runtime):
"""
A scaling group is a group of Elastic Compute Service (ECS) instances that can be used in similar business scenarios.
You can create only a limited number of scaling groups in a region. Go to Quota Center to check the quota of the scaling groups.
A scaling group does not immediately take effect after you create the scaling group. You must call the EnableScalingGroup operation to enable the scaling group. After you enable the scaling group, Auto Scaling can execute scaling rules to trigger scaling activities in the scaling group.
The Classic Load Balancer (CLB) instances and ApsaraDB RDS instances that you want to associate with a scaling group must reside in the same region as the scaling group. CLB instances are formerly known as Server Load Balancer (SLB) instances. For more information, see the [Regions and zones](~~40654~~) topic.
If you associate a CLB instance when you create a scaling group, Auto Scaling automatically adds ECS instances in the scaling group to the backend server group of the associated CLB instance. You can specify a server group to which ECS instances can be added. You can add ECS instances to the following types of server groups:
* Default server group: a group of ECS instances that are used to receive requests. If you do not specify a vServer group or a primary/secondary server group for a listener, requests are forwarded to the ECS instances in the default server group.
* vServer group: If you want to forward requests to backend servers that are not in the default server group or configure domain name-based or URL-based forwarding rules, you can use vServer groups.
> If you specify the default server group and multiple vServer groups at the same time, ECS instances are added to all specified server groups.
The default weight of an ECS instance that is added as a backend server of a CLB instance is 50. The CLB instance that you want to associate with your scaling group must meet the following requirements:
* The CLB instance must be in the Active state. You can call the DescribeLoadBalancers operation to query the state of the CLB instance.
* The health check feature must be enabled on all listener ports that are configured for the CLB instance. Otherwise, the scaling group fails to be created.
If you associate an Application Load Balancer (ALB) server group with a scaling group, Auto Scaling automatically adds ECS instances that are in the scaling group to the ALB server group to process requests distributed by the ALB instance to which the ALB server group belongs. You can specify multiple ALB server groups. The server groups must reside in the same virtual private cloud (VPC) as the scaling group. For more information, see the "AttachAlbServerGroups" topic.
If you associate an ApsaraDB RDS instance with a scaling group, Auto Scaling automatically adds the private IP addresses of the ECS instances in the scaling group to the IP address whitelist of the ApsaraDB RDS instance. The ApsaraDB RDS instance that you want to associate with your scaling group must meet the following requirements:
* The ApsaraDB RDS instance must be in the Running state. You can call the DescribeDBInstances operation to query the state of the ApsaraDB RDS instance.
* The number of IP addresses in the IP address whitelist of the ApsaraDB RDS instance cannot exceed the upper limit. For more information, see the "Configure whitelists" topic.
If you set the MultiAZPolicy parameter of the scaling group to COST_OPTIMIZED, take note of the following items:
* You can use the OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, and SpotInstancePools parameters to specify the instance allocation method based on the cost optimization policy. This instance allocation method is prioritized during scaling.
* If you do not specify the OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, or SpotInstancePools parameter, the instance types that are provided at the lowest price are used to create instances based on the cost optimization policy.
If you set the `Tags.Propagate` parameter of the scaling group to true, the following rules apply:
* Tags that you add to the scaling group cannot be propagated to existing instances in the scaling group. Tags that you add to the scaling group are propagated to only new instances.
* If you specify instance tags in the scaling configuration that is used to create instances and propagate the tags that you add to the scaling group to the instances, all tags exist at the same time.
* If the tag key that you specify in a scaling configuration and the tag key that you add to the scaling group of the scaling configuration are the same, the tag value that you specify in the scaling configuration is preferentially used.
@param request: CreateScalingGroupRequest
@param runtime: runtime options for this request RuntimeOptions
@return: CreateScalingGroupResponse
"""
UtilClient.validate_model(request)
query = {}
if not UtilClient.is_unset(request.alb_server_groups):
query['AlbServerGroups'] = request.alb_server_groups
if not UtilClient.is_unset(request.allocation_strategy):
query['AllocationStrategy'] = request.allocation_strategy
if not UtilClient.is_unset(request.az_balance):
query['AzBalance'] = request.az_balance
if not UtilClient.is_unset(request.client_token):
query['ClientToken'] = request.client_token
if not UtilClient.is_unset(request.compensate_with_on_demand):
query['CompensateWithOnDemand'] = request.compensate_with_on_demand
if not UtilClient.is_unset(request.container_group_id):
query['ContainerGroupId'] = request.container_group_id
if not UtilClient.is_unset(request.custom_policy_arn):
query['CustomPolicyARN'] = request.custom_policy_arn
if not UtilClient.is_unset(request.dbinstance_ids):
query['DBInstanceIds'] = request.dbinstance_ids
if not UtilClient.is_unset(request.dbinstances):
query['DBInstances'] = request.dbinstances
if not UtilClient.is_unset(request.default_cooldown):
query['DefaultCooldown'] = request.default_cooldown
if not UtilClient.is_unset(request.desired_capacity):
query['DesiredCapacity'] = request.desired_capacity
if not UtilClient.is_unset(request.group_deletion_protection):
query['GroupDeletionProtection'] = request.group_deletion_protection
if not UtilClient.is_unset(request.group_type):
query['GroupType'] = request.group_type
if not UtilClient.is_unset(request.health_check_type):
query['HealthCheckType'] = request.health_check_type
if not UtilClient.is_unset(request.health_check_types):
query['HealthCheckTypes'] = request.health_check_types
if not UtilClient.is_unset(request.instance_id):
query['InstanceId'] = request.instance_id
if not UtilClient.is_unset(request.launch_template_id):
query['LaunchTemplateId'] = request.launch_template_id
if not UtilClient.is_unset(request.launch_template_overrides):
query['LaunchTemplateOverrides'] = request.launch_template_overrides
if not UtilClient.is_unset(request.launch_template_version):
query['LaunchTemplateVersion'] = request.launch_template_version
if not UtilClient.is_unset(request.lifecycle_hooks):
query['LifecycleHooks'] = request.lifecycle_hooks
if not UtilClient.is_unset(request.load_balancer_configs):
query['LoadBalancerConfigs'] = request.load_balancer_configs
if not UtilClient.is_unset(request.load_balancer_ids):
query['LoadBalancerIds'] = request.load_balancer_ids
if not UtilClient.is_unset(request.max_instance_lifetime):
query['MaxInstanceLifetime'] = request.max_instance_lifetime
if not UtilClient.is_unset(request.max_size):
query['MaxSize'] = request.max_size
if not UtilClient.is_unset(request.min_size):
query['MinSize'] = request.min_size
if not UtilClient.is_unset(request.multi_azpolicy):
query['MultiAZPolicy'] = request.multi_azpolicy
if not UtilClient.is_unset(request.on_demand_base_capacity):
query['OnDemandBaseCapacity'] = request.on_demand_base_capacity
if not UtilClient.is_unset(request.on_demand_percentage_above_base_capacity):
query['OnDemandPercentageAboveBaseCapacity'] = request.on_demand_percentage_above_base_capacity
if not UtilClient.is_unset(request.owner_account):
query['OwnerAccount'] = request.owner_account
if not UtilClient.is_unset(request.owner_id):
query['OwnerId'] = request.owner_id
if not UtilClient.is_unset(request.region_id):
query['RegionId'] = request.region_id
if not UtilClient.is_unset(request.removal_policies):
query['RemovalPolicies'] = request.removal_policies
if not UtilClient.is_unset(request.resource_group_id):
query['ResourceGroupId'] = request.resource_group_id
if not UtilClient.is_unset(request.resource_owner_account):
query['ResourceOwnerAccount'] = request.resource_owner_account
if not UtilClient.is_unset(request.scaling_group_name):
query['ScalingGroupName'] = request.scaling_group_name
if not UtilClient.is_unset(request.scaling_policy):
query['ScalingPolicy'] = request.scaling_policy
if not UtilClient.is_unset(request.server_groups):
query['ServerGroups'] = request.server_groups
if not UtilClient.is_unset(request.spot_allocation_strategy):
query['SpotAllocationStrategy'] = request.spot_allocation_strategy
if not UtilClient.is_unset(request.spot_instance_pools):
query['SpotInstancePools'] = request.spot_instance_pools
if not UtilClient.is_unset(request.spot_instance_remedy):
query['SpotInstanceRemedy'] = request.spot_instance_remedy
if not UtilClient.is_unset(request.sync_alarm_rule_to_cms):
query['SyncAlarmRuleToCms'] = request.sync_alarm_rule_to_cms
if not UtilClient.is_unset(request.tags):
query['Tags'] = request.tags
if not UtilClient.is_unset(request.vserver_groups):
query['VServerGroups'] = request.vserver_groups
if not UtilClient.is_unset(request.v_switch_id):
query['VSwitchId'] = request.v_switch_id
if not UtilClient.is_unset(request.v_switch_ids):
query['VSwitchIds'] = request.v_switch_ids
req = open_api_models.OpenApiRequest(
query=OpenApiUtilClient.query(query)
)
params = open_api_models.Params(
action='CreateScalingGroup',
version='2022-02-22',
protocol='HTTPS',
pathname='/',
method='POST',
auth_type='AK',
style='RPC',
req_body_type='formData',
body_type='json'
)
return TeaCore.from_map(
ess_20220222_models.CreateScalingGroupResponse(),
self.call_api(params, req, runtime)
)