Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Auto Scaling/ API Reference/ Application Examples/ Example 2: Creating an AS Group

Example 2: Creating an AS Group

Updated on 2024-05-23 GMT+08:00

Scenarios

This section describes how to create an AS group by calling APIs. For details, see Calling APIs.

An AS group consists of a collection of instances that apply to the same scenario. It is the basis for enabling or disabling AS policies and performing scaling actions. An AS group specifies parameters, such as the maximum number of instances, expected number of instances, minimum number of instances, VPC, subnet, and load balance settings.

Constraints

  • Up to 10 AS groups per account can be created by default.
  • If ELB is configured, AS automatically binds or unbinds a load balancer to or from an instance when the instance is added or removed from the AS group.
  • If an AS group uses ELB health check, the listening ports on the load balancers must be enabled for the instances in the AS group. Enable the listening ports in security groups. For details, see Adding a Security Group Rule.

Involved APIs

To create an AS group, you need to perform several operations, such as querying a user token, security groups, and AS configurations. The following APIs are required:

Procedure

  1. Determine the user token that can be used to authenticate the calling of other APIs.

    1. View the user token. For details, see Obtaining a User Token.
    2. Obtain the value of X-Subject-Token in the response header.

  2. Determine the VPC.

    1. View VPCs. For details, see Querying VPCs.
    2. Select a VPC based on site requirements and record the VPC ID.

  1. Determine the security group.

    1. View security groups. For details, see Querying Security Groups.
    2. Select a security group based on site requirements and record the security group ID.

  1. Determine the subnet.

    1. View subnets in the specified VPC based on VPC ID. For details, see Querying Subnets.
    2. Select a subnet based on site requirements and record the subnet ID.

  1. Determine the AS configuration.

    1. View AS configurations.
      • API

      URI format: GET /autoscaling-api/v1/{project_id}/scaling_configuration

      For details about the API request parameters, see Querying AS Configurations.

      • Example request

      GET: https://{Endpoint}/autoscaling-api/v1/0605767c2e80d5762fd0c0146a10aaf2/scaling_configuration?start_number=0&limit=10

      Obtain {endpoint} from Regions and Endpoints.

      • Example response
        {
            "limit": 20,
            "total_number": 2,
            "start_number": 0,
            "scaling_configurations": [
                {
                    "tenant": "ce061903a53545dcaddb300093b477d2",
                    "scaling_configuration_id": "6afe46f9-7d3d-4046-8748-3b2a1085ad86",
                    "scaling_configuration_name": " config_name_1",
                    "instance_config": {
                        "disk": [
                            {
                                "size": 40,
                                "volume_type": "SATA",
                                "disk_type": "SYS"
                            },
                            {
                                "size": 100,
                                "volume_type": "SATA",
                                "disk_type": "DATA"
                            }
                        ],
                        "personality": null,
                        "instance_name": null,
                        "instance_id": null,
                        "flavorRef": "103",
                        "imageRef": "37ca2b35-6fc7-47ab-93c7-900324809c5c",
                        "key_name": "keypair01",
                        "public_ip": null,
                        "user_data": null,
                        "metadata": {},
                        "security_groups": [{
                             "id": "6c22a6c0-b5d2-4a84-ac56-51090dcc33be"
                        }],
                    },
                    "create_time": "2015-07-23T01:04:07Z"
                }
            ]
        }

    1. Select an AS configuration based on site requirements and record the AS configuration ID.

  1. Determine the AZ.

    1. View AZs. For details, see Querying AZs.
    2. Select an AZ as required and record the AZ name.

  1. Create an AS group using the VPC and AS configuration you specify.

    • API

      URI format: POST /autoscaling-api/v1/{project_id}/scaling_group

      For details about the API request parameters, see Creating an AS Group.

    • Example request

      POST: https://{Endpoint}/autoscaling-api/v1/0605767c2e80d5762fd0c0146a10aaf2/scaling_group

      Obtain {endpoint} from Regions and Endpoints.

      Body:

      {
      "scaling_group_name": "GroupNameTest",
      "scaling_configuration_id": "47683a91-93ee-462a-a7d7-484c006f4440",
      "desire_instance_number": 0,
      "min_instance_number": 0,
      "max_instance_number": 10,
      "health_periodic_audit_method": "NOVA_AUDIT",
      "vpc_id": "a8327883-6b07-4497-9c61-68d03ee193a",
      "available_zones": ["XXXa","XXXb"],
      "networks": [
              {
                   "id": "3cd35bca-5a10-416f-8994-f79169559870"
               }
      ],
      "enterprise_project_id": "c92b1a5d-6f20-43f2-b1b7-7ce35e58e413",
      "multi_az_priority_policy": "PICK_FIRST"
      }

    • Example response
      {
          "scaling_group_id": "a8327883-6b07-4497-9c61-68d03ee193a1"
      }

  2. Verify the AS group creation.

    • API

      URI format: GET /autoscaling-api/v1/{project_id}/scaling_group/{scaling_group_id}

      For details about the API request parameters, see Querying an AS Group.

    • Example request

      GET: https://{Endpoint}/autoscaling-api/v1/0605767c2e80d5762fd0c0146a10aaf2/scaling_group/a8327883-6b07-4497-9c61-68d03ee193a1

      where

      a8327883-6b07-4497-9c61-68d03ee193a1 is the UUID of the created AS configuration.

      Obtain {endpoint} from Regions and Endpoints.

    • Example response
      {
          "scaling_group": {
            "networks": [
                      {
                          "id": "a8327883-6b07-4497-9c61-68d03ee193a ",
                          "ipv6_enable": true,
                          "ipv6_bandwidth": 
                              {         
                                    "id": "076ee2ff-f23e-4338-b8ac-1bc7278532d5"
                              }
                      }
              ],
              "available_zones": [
                     "XXXa",
                     "XXXb"
              ],
              "detail": null,
              "scaling_group_name": "api_gateway_modify",
              "scaling_group_id": "d4e50321-3777-4135-97f8-9f5e9714a4b0",
              "scaling_group_status": "INSERVICE",
              "scaling_configuration_id": "53579851-3841-418d-a97b-9cecdb663a90",
              "scaling_configuration_name": "press",
              "current_instance_number": 7,
              "desire_instance_number": 8,
              "min_instance_number": 0,
              "max_instance_number": 100,
              "cool_down_time": 900,
              "lb_listener_id": null,
              "security_groups": [
                  {
                      "id": "23b7b999-0a30-4b48-ae8f-ee201a88a6ab"
                  }
              ],
              "create_time": "2015-09-01T08:36:10Z",
              "vpc_id": "3e22f934-800d-4bb4-a588-0b9a76108190",
              "health_periodic_audit_method": "NOVA_AUDIT",
              "health_periodic_audit_time": 5,
              "health_periodic_audit_grace_period": 600,
              "instance_terminate_policy": "OLD_CONFIG_OLD_INSTANCE",
              "is_scaling": true,
              "delete_publicip": false,
              "notifications": null,
              "enterprise_project_id": "c92b1a5d-6f20-43f2-b1b7-7ce35e58e413",
              "activity_type": "MODIFY_ELB",
              "multi_az_priority_policy": "PICK_FIRST"
          }
      }

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback