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

创建VPC

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

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

本文介绍如何创建一个VPC。

示例代码

# 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()

    # 创建一个VPC
    create_vpc_request = volcenginesdkvpc.CreateVpcRequest(
        cidr_block="172.XX.XX.0/12",   # VPC的网段
        description="test",            # VPC的描述
        dns_servers=["1.XX.XX.1"],     # VPC的DNS服务器地址
        vpc_name="test",               # VPC的名称
    )

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

相关文档