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

创建VPN网关

最近更新时间2023.07.05 15:21:26

首次发布时间2023.07.05 15:21:26

本文介绍如何创建VPN网关。

示例代码

# Example Code generated by Beijing Volcanoengine Technology.
from __future__ import print_function
import volcenginesdkcore
import volcenginesdkvpn
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 = volcenginesdkvpn.VPNApi()
    # 配置待创建VPN网关的参数。
    create_vpn_gateway_request = volcenginesdkvpn.CreateVpnGatewayRequest(
        bandwidth=5, # 设置VPN网关出云方向的带宽规格,单位:Mbps。取值:5、10、20、50、100、200、500、1000。
        billing_type=1, # 设置VPN网关的计费类型,1(包年包月)。
        description="test", # 设置VPN网关的描述信息。
        period=1, # 设置包年包月类型VPN网关购买的时长。
        period_unit="Month", # 设置包年包月类型VPN网关购买时长的单位,Month(月),Year(年)。
        subnet_id="subnet-2fewbgn7jbk0059gp67ap****", # 设置VPN网关使用子网的ID。
        vpc_id="vpc-12bhs1ivo6p6o17q7y2x3****", # 设置VPN网关所在VPC的ID。
        vpn_gateway_name="test", # 设置VPN网关的名称。
    )

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

相关文档