Updated on 2022-02-22 GMT+08:00

Creating an AS Group

This section describes how to create an AS group by calling a series of AS APIs.

The validity period of a token obtained from IAM is 24 hours. If you want to use a token for authentication, cache it to avoid frequently calling the IAM API.

Involved APIs

To use token authentication, you need to obtain a token and add X-Auth-Token to the request header of API calls.

  • API for obtaining tokens from IAM
  • APIs used to create an AS group

Procedure

  1. Obtain the token by following instructions in Authentication.
  2. Obtain the project ID (project_id). For details, see Obtaining a Project ID.
  3. Add the Content-Type key to the request header. The value of Content-Type is application/json.
  4. Add the X-Auth-Token key to the request header. The value is the token obtained in 1.
  5. Send POST https://AS endpoint/v1/{project_id}/scaling_group. project_id is the project ID obtained in step 2.
  6. Specify the following parameters in the request body:
    {
        "scaling_group_name": "GroupNameTest",//AS group name (This is a mandatory string.)
        "scaling_configuration_id": "47683a91-93ee-462a-a7d7-484c006f4440",//AS configuration ID (This is an optional string, but an AS group to be enabled must have an AS configuration.)
        "desire_instance_number": 0,//Expected instances (This is an optional integer.)
        "min_instance_number": 0,//Minimum instances (This is an optional integer.)
        "max_instance_number": 0,//Maximum instances (This is an optional integer.)
        "cool_down_time": 200,//Cooldown period (This is an optional integer.)
        "health_periodic_audit_method": "NOVA_AUDIT",//Instance health check method (This is an optional string.)
        "health_periodic_audit_time": 5,//Instance health check period (This is an optional integer.)
        "instance_terminate_policy": "OLD_CONFIG_OLD_INSTANCE",//Instance removal policy (This is an optional string.)
        "vpc_id": "a8327883-6b07-4497-9c61-68d03ee193a",//VPC information (This is a mandatory string.)
        "networks": [
            {
                "id": "3cd35bca-5a10-416f-8994-f79169559870"
            }
        ]//Subnet information (This is a mandatory list data structure.)
    } 

    If the request is responded, scaling_group_id is returned, indicating that the AS group is successfully created.

    If the request fails, an error code and error information are returned. For details, see Error Codes.

  7. You can query, modify, and delete an AS group based on the obtained scaling_group_id.