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

路由表关联子网

最近更新时间2023.06.09 11:20:34

首次发布时间2023.06.09 11:20:34

本文介绍如何为自定义路由表关联子网。

示例代码

# Example Code generated by Beijing Volcanoengine Technology.
from __future__ import print_function
import volcenginesdkcore
import volcenginesdkvpc
from pprint import pprint
from volcenginesdkcore.rest import ApiException

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

    # 使用全局默认配置
    api_instance = volcenginesdkvpc.VPCApi()

    # 为自定义路由表关联子网
    associate_route_table_request = volcenginesdkvpc.AssociateRouteTableRequest(
        route_table_id="vtb-2fdzao4h726f45****",     # 路由表的ID
        subnet_id="subnet-2fdzaou4liw3k5oxruv****",  # 子网的ID
    )

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

相关文档