tencent cloud

Feedback

CreateAutoScalingGroup

Last updated: 2024-12-03 17:50:39

    1. API Description

    Domain name for API request: as.intl.tencentcloudapi.com.

    This API (CreateAutoScalingGroup) is used to create an auto scaling group.

    A maximum of 20 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: CreateAutoScalingGroup.
    Version Yes String Common Params. The value used for this API: 2018-04-19.
    Region Yes String Common Params. For more information, please see the list of regions supported by the product.
    AutoScalingGroupName Yes String Auto scaling group name, which can only contain letters, numbers, underscores, hyphens ("-"), and decimal points with a maximum length of 55 bytes and must be unique under your account.
    LaunchConfigurationId Yes String Launch configuration ID
    MaxSize Yes Integer Maximum number of instances. Value range: 0-2,000.
    MinSize Yes Integer Minimum number of instances. Value range: 0-2,000.
    VpcId Yes String VPC ID; if on a basic network, enter an empty string
    DefaultCooldown No Integer Default cooldown period in seconds. Default value: 300
    DesiredCapacity No Integer Desired number of instances. The number should be no larger than the maximum and no smaller than minimum number of instances
    LoadBalancerIds.N No Array of String List of classic CLB IDs. Currently, the maximum length is 20. You cannot specify LoadBalancerIds and ForwardLoadBalancers at the same time.
    ProjectId No Integer Project ID of an instance in a scaling group. The default project is used if it’s left blank.
    ForwardLoadBalancers.N No Array of ForwardLoadBalancer List of application CLBs. Up to 100 CLBs are allowed. LoadBalancerIds and ForwardLoadBalancers cannot be specified at the same time.
    SubnetIds.N No Array of String List of subnet IDs. A subnet must be specified in the VPC scenario. If multiple subnets are entered, their priority will be determined by the order in which they are entered, and they will be tried one by one until instances can be successfully created.
    TerminationPolicies.N No Array of String Termination policy, whose maximum length is currently 1. Valid values: OLDEST_INSTANCE and NEWEST_INSTANCE. Default value: OLDEST_INSTANCE.
  • OLDEST_INSTANCE: Terminate the oldest instance in the scaling group first.
  • NEWEST_INSTANCE: Terminate the newest instance in the scaling group first.
  • Zones.N No Array of String List of availability zones. An availability zone must be specified in the basic network scenario. If multiple availability zones are entered, their priority will be determined by the order in which they are entered, and they will be tried one by one until instances can be successfully created.
    RetryPolicy No String Retry policy. Valid values: IMMEDIATE_RETRY, INCREMENTAL_INTERVALS, and NO_RETRY. Default value: IMMEDIATE_RETRY. A partially successful scaling activity is considered a failed activity.
  • IMMEDIATE_RETRY: Immediately retry or quickly retry in a short period. There will be no retry anymore after a certain number of consecutive failures (5).
  • INCREMENTAL_INTERVALS: Retry at an incremental interval. As the number of continuous failures increase, the retry interval gradually increases. The interval for the first 10 retries is the same as the immediate retry mode, and that for the subsequent retries gradually increases to 10 minutes, 30 minutes, 60 minutes, or 1 day.
  • NO_RETRY: There will be no retry until another user call or alarm information is received.
  • ZonesCheckPolicy No String AZ verification policy. Valid values: ALL and ANY. Default value: ANY.
  • ALL: Verification passes if all AZs or subnets are available; otherwise, a verification error will be reported.

  • ANY: Verification passes if any AZ or subnet is available; otherwise, a verification error will be reported.


  • Common reasons for unavailable AZs or subnets include the CVM InstanceType in the AZ being sold out, the CBS cloud disk in the AZ being sold out, insufficient quota in the AZ, and insufficient IP addresses in the subnet.
    If there is no AZ or subnet in Zones/SubnetIds, a verification error will be reported regardless of the values of ZonesCheckPolicy.
    Tags.N No Array of Tag List of tag descriptions. In this parameter, you can specify the tags to be bound with a scaling group as well as corresponding resource instances. Each scaling group can have up to 30 tags.
    ServiceSettings No ServiceSettings Service settings such as unhealthy instance replacement.
    Ipv6AddressCount No Integer The number of IPv6 addresses that an instance has. Valid values: 0 and 1. Default value: 0.
    MultiZoneSubnetPolicy No String Multi-AZ/multi-subnet policy, whose valid values include PRIORITY and EQUALITY, with the default value being PRIORITY.
  • PRIORITY: The instances are attempted to be created taking the order of the AZ/subnet list as the priority. If instances can be successfully created in the highest-priority AZ/subnet, they will always be created in that AZ/subnet.
  • EQUALITY: The instances added through scale-out will be distributed across multiple AZs/subnets to ensure a relatively balanced number of instances in each AZ/subnet after scaling out.


  • Points to consider regarding this policy:
  • When the scaling group is based on a classic network, this policy applies to the multi-AZ; when the scaling group is based on a VPC network, this policy applies to the multi-subnet, in this case, the AZs are no longer considered. For example, if there are four subnets labeled A, B, C, and D, where A, B, and C are in AZ 1 and D is in AZ 2, the subnets A, B, C, and D are considered for sorting without regard to AZs 1 and 2.
  • This policy applies to the multi-AZ/multi-subnet and not to the InstanceTypes parameter of the launch configuration, which is selected according to the priority policy.
  • When instances are created according to the PRIORITY policy, ensure the policy for multiple models first, followed by the policy for the multi-AZ/subnet. For example, with models A and B and subnets 1, 2, and 3, attempts will be made in the order of A1, A2, A3, B1, B2, and B3. If A1 is sold out, A2 will be attempted (instead of B1).
  • HealthCheckType No String Health check type for scaling group instances. Valid values:
  • CVM: Determine whether an instance is unhealthy based on its network status. An unhealthy network status is indicated by an event where instances become unreachable via PING. For detailed criteria of judgment, see Instance Health Check.
  • CLB: Determine whether an instance is unhealthy based on the health check status of CLB. For principles behind CLB health checks, see Health Check Overview.

  • If CLB is selected, the scaling group will check both the instance's network status and the CLB's health check status. If the instance's network status is unhealthy, the instance will be marked as UNHEALTHY. If the CLB's health check status is abnormal, the instance will be marked as CLB_UNHEALTHY. If both of them are abnormal, the instance will be marked as UNHEALTHY|CLB_UNHEALTHY. Default value: CLB.
    LoadBalancerHealthCheckGracePeriod No Integer Grace period of the CLB health check during which the IN_SERVICE instances added will not be marked as CLB_UNHEALTHY.
    Valid range: 0-7200, in seconds. Default value: 0.
    InstanceAllocationPolicy No String Instance assignment policy. Valid values: LAUNCH_CONFIGURATION and SPOT_MIXED. Default value: LAUNCH_CONFIGURATION.
  • LAUNCH_CONFIGURATION: Represent the traditional mode of assigning instances according to the launch configuration.
  • SPOT_MIXED: Represent the spot mixed mode. Currently, this mode is supported only when the launch configuration is set to the pay-as-you-go billing mode. In the mixed mode, the scaling group will scale out pay-as-you-go models or spot models based on the predefined settings. When the mixed mode is used, the billing type of the associated launch configuration cannot be modified.
  • SpotMixedAllocationPolicy No SpotMixedAllocationPolicy Specifies how to assign pay-as-you-go instances and spot instances.
    This parameter is valid only when InstanceAllocationPolicy is set to SPOT_MIXED.
    CapacityRebalance No Boolean Capacity rebalancing feature, which is applicable only to spot instances within the scaling group. Valid values:
  • TRUE: Enable this feature. When spot instances in the scaling group are about to be automatically recycled by the spot instance service, AS proactively initiates the termination process of the spot instances. If there is a configured scale-in hook, it will be triggered before termination. After the termination process starts, AS asynchronously initiates the scale-out to reach the expected number of instances.
  • FALSE: Disable this feature. AS waits for the spot instance to be terminated before scaling out to reach the number of instances expected by the scaling group.


  • Default value: FALSE.
    InstanceNameIndexSettings No InstanceNameIndexSettings Instance name sequencing settings. If this parameter is not specified, the default is not enabled. When enabled, an incremental numeric sequence will be appended to the names of instances automatically created within the scaling group.

    3. Output Parameters

    Parameter Name Type Description
    AutoScalingGroupId String Auto scaling group ID
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Creating an auto scaling group

    This example shows how to create an auto scaling group in a specified VPC and configure a layer-7 load balancer.

    Input Example

    https://as.intl.tencentcloudapi.com/?Action=CreateAutoScalingGroup
    &AutoScalingGroupName=asg-vpc-7layer-lb
    &DefaultCooldown=300
    &DesiredCapacity=0
    &LaunchConfigurationId=asc-7vucy6ae
    &MaxSize=10
    &MinSize=0
    &ProjectId=0
    &VpcId=vpc-hy436tmc
    &SubnetIds.0=subnet-3tmerl37
    &SubnetIds.1=subnet-b0vxjhot
    &TerminationPolicies.0=OLDEST_INSTANCE
    &ForwardLoadBalancers.0.LoadBalancerId=lb-23aejgcv
    &ForwardLoadBalancers.0.ListenerId=lbl-ncw704sn
    &ForwardLoadBalancers.0.LocationId=loc-l3hmaev9
    &ForwardLoadBalancers.0.Region=ap-guangzhou
    &ForwardLoadBalancers.0.TargetAttributes.0.Port=8080
    &ForwardLoadBalancers.0.TargetAttributes.0.Weight=10
    &<common request parameters>
    

    Output Example

    {
        "Response": {
            "AutoScalingGroupId": "asg-nkdwoui0",
            "RequestId": "a5d66fed-85b9-4f43-8243-597337ba896e"
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    InternalError An internal error occurred.
    InternalError.CallLbError CLB API call failed.
    InternalError.CallTagError The tag API call failed.
    InternalError.CallTvpcError The TVPC API call failed.
    InternalError.CallVpcError VPC API call failed.
    InternalError.RequestError An internal request error occurred.
    InvalidParameter.ActionNotFound Invalid Action request.
    InvalidParameter.InScenario The parameter is invalid in a specific scenario.
    InvalidParameterValue.BaseCapacityTooLarge The specified base capacity cannot exceed the max capacity.
    InvalidParameterValue.ClassicLb A classic CLB should be specified.
    InvalidParameterValue.CvmError Exception with CVM parameter validation.
    InvalidParameterValue.DuplicatedForwardLb Duplicate CLB instances
    InvalidParameterValue.DuplicatedSubnet Duplicated subnet.
    InvalidParameterValue.ForwardLb A CLB should be specified.
    InvalidParameterValue.GroupNameDuplicated The auto scaling group name already exists.
    InvalidParameterValue.InvalidClbRegion The regions specified for CLB is invalid.
    InvalidParameterValue.InvalidLaunchConfigurationId Invalid launch configuration ID.
    InvalidParameterValue.InvalidSubnetId Invalid subnet ID.
    InvalidParameterValue.LaunchConfigurationNotFound The specified launch configuration was not found.
    InvalidParameterValue.LbProjectInconsistent The load balancer is in a different project.
    InvalidParameterValue.LimitExceeded The value exceeds the limit.
    InvalidParameterValue.ListenerTargetTypeNotSupported Target group listeners are not supported.
    InvalidParameterValue.OnlyVpc The account only supports VPCs.
    InvalidParameterValue.ProjectIdNotFound The project ID does not exist.
    InvalidParameterValue.Range The value is outside the specified range.
    InvalidParameterValue.Size The value of maximum, minimum, or desired number of instances in the auto scaling group is invalid.
    InvalidParameterValue.SubnetIds The subnet information is invalid.
    InvalidParameterValue.TargetPortDuplicated The backend port of the CLB layer-4 listener already exists.
    InvalidParameterValue.TooLong Too many values.
    InvalidParameterValue.ZoneMismatchRegion The specified availability zone is not in the region.
    LimitExceeded The quota limit is exceeded.
    LimitExceeded.AutoScalingGroupLimitExceeded The number of auto scaling groups exceeds the limit.
    LimitExceeded.MaxSizeLimitExceeded The maximum number of instances exceeds the limit.
    LimitExceeded.MinSizeLimitExceeded The minimum number of instances is below the limit.
    MissingParameter.InScenario A parameter is missing in a specific scenario.
    ResourceNotFound.ListenerNotFound The specified listener does not exist.
    ResourceNotFound.LoadBalancerNotFound The specified load balancer was not found.
    ResourceNotFound.LocationNotFound The specified location does not exist.
    ResourceUnavailable.LaunchConfigurationStatusAbnormal The launch configuration is exceptional.
    ResourceUnavailable.LbBackendRegionInconsistent The backend region of the CLB is not the same as the one for AS service.
    ResourceUnavailable.LbVpcInconsistent The CLB and scaling group should reside in the same VPC.
    ResourceUnavailable.ProjectInconsistent Project inconsistency.
    ResourceUnavailable.ZoneUnavailable The specified availability zone is unavailable.