You need to enable JavaScript to run this app.
导航

创建伸缩组

最近更新时间2023.07.19 17:54:47

首次发布时间2023.07.19 17:54:47

本文介绍如何创建伸缩组。

示例代码

from __future__ import print_function
import volcenginesdkcore
import volcenginesdkautoscaling
from pprint import pprint
from volcenginesdkcore.rest import ApiException

if __name__ == '__main__':
    configuration = volcenginesdkcore.Configuration()
    # 设置您的ak、sk和要访问的地域
    configuration.ak = "AK"
    configuration.sk = "SK"
    configuration.region = "cn-beijing"
    # 设置默认配置
    volcenginesdkcore.Configuration.set_default(configuration)

    # 使用全局默认配置
    api_instance = volcenginesdkautoscaling.AUTOSCALINGApi()

    # 创建伸缩组
    create_scaling_group_request = volcenginesdkautoscaling.CreateScalingGroupRequest(
        max_instance_number=10,# 伸缩组中实例个数的最大值
        min_instance_number=1,# 伸缩组中实例个数的最小值
        scaling_group_name="scaling-group-test",# 伸缩组名称
        subnet_ids=["subnet-inaimn26s8ow8gbssyxi****"],# 伸缩组中实例主网卡的子网ID
    )

		# 发起请求并处理返回或异常
     try:
        resp = api_instance.create_scaling_group(create_scaling_group_request)
        pprint(resp)
    except ApiException as e:
        print("Exception when calling api: %s\n" % e)

相关文档