You need to enable JavaScript to run this app.
导航
创建NAT网关
最近更新时间:2023.06.09 11:16:55首次发布时间:2023.06.09 11:16:55

本文介绍如何创建一台NAT网关。

示例代码

# Example Code generated by Beijing Volcanoengine Technology.
from __future__ import print_function
import volcenginesdkcore
import volcenginesdknatgateway
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 = volcenginesdknatgateway.NATGATEWAYApi()

    # 创建NAT网关
    create_nat_gateway_request = volcenginesdknatgateway.CreateNatGatewayRequest(
        spec="Small", # NAT网关的规格
        subnet_id="subnet-2feypga30rgg059gp67ag****", # NAT网关所属子网的ID
        vpc_id="vpc-2feypfmenesqo59gp67yz****",       # NAT网关所属VPC的ID
    )

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

相关文档