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

CreateNatGateway

最近更新时间2024.03.21 19:17:16

首次发布时间2021.12.28 08:28:52

调用 CreateNatGateway 接口,创建一个NAT网关实例。

调用说明

前提条件

在目标VPC内创建首个NAT网关前,目标VPC系统路由表中不存在目标网段为0.0.0.0/0的路由条目。您可调用 DescribeRouteTableList接口,查询系统路由表的ID,调用 DescribeRouteEntryList 接口,查看系统路由表是否存在目标网段为0.0.0.0/0的路由条目。若存在,可调用 DeleteRouteEntry 接口删除路由条目。

使用限制

  • 单个VPC最多可创建的NAT网关数量为3个。

  • 创建完成后,您可调用 AssociateEipAddress 为NAT网关绑定公网IP。单个NAT网关默认最多绑定10个公网IP,若默认配额无法满足需要,请前往 配额中心 提升相应配额。

  • 公网IP的优先级高于路由表,若云服务器实例绑定了公网IP,则其流量通过公网IP转发,无法使用NAT网关的功能。

  • 标签的其他操作请参考 TagResourcesUntagResourcesListTagsForResources

请求参数

参数名称
类型
是否必选
示例值
描述
ActionStringCreateNatGateway要执行的操作,取值:CreateNatGateway。
VersionString2020-04-01API的版本信息,当前版本为:2020-04-01。

NatGatewayName

String

nat-01

NAT网关的名称。

  • 长度限制为1 ~ 128个字符。
  • 需要以字母、中文或数字开头,可包含点号(.)、下划线(_)和短划线(-)。
  • 不填默认为NAT网关的ID。

Description

String

This is a nat

NAT网关的描述。

  • 长度限制为0~ 255个字符。
  • 不填默认为空字符串。
  • 需要以字母、中文或数字开头。可包含英文逗号(,)、点号(.)、下划线(_)、空格( )、等号(=)、短横线(-)、中文逗号(,)、中文句号(。)。

Spec

String

Medium

NAT网关的规格。取值如下:

  • Small(默认):小型。
  • Medium:中型。
  • Large:大型。

BillingType

Integer

1

NAT网关的计费方式。取值如下:

  • 1:包年包月。
  • 2(默认):按量计费。

PeriodUnit

String

Month

购买包年包月NAT网关时长的单位。取值如下:

  • Month(默认) :月。
  • Year :年。

Period

Integer

3

购买包年包月NAT网关的时长,默认1。

  • PeriodUnit传入Month,Period取值范围:1 ~ 9、12、24、36。
  • PeriodUnit传入Year,Period取值范围:1 ~ 3。

VpcId

String

vpc-2feypfmenesqo59gp67yz****

NAT网关所在私有网络的ID。
您可以调用 DescribeVpcs 接口,查询VPC的ID。

SubnetId

String

subnet-2feypga30rgg059gp67ag****

NAT网关所在子网的ID。

  • 传入的子网,必须是VpcId传入的私有网络的子网。
  • 子网内至少有一个可用的私网IP。系统自动生成的NAT网关网卡将占用该子网一个私网IP。
  • 子网所在的可用区需要已部署NAT网关资源。您可调用 DescribeSubnets 查询私有网络下子网所在的可用区,同时您可以调用 ListNatGatewayAvailableZones 查询下当前地域下有NAT网关资源的可用区。子网所在可用区将作为NAT网关的主可用区,并自动关联备可用区。当主可用区发生故障时,NAT网关自动切换到备可用区。
ProjectNameStringProject_1NAT网关所属项目的名称。不填默认加入default项目。

Tags.N.Key

String

Tags.1.Key=key1&Tags.2.Key=key2

用户标签的标签键。

  • 参数 - N:表示标签键的序号,取值范围:1~50。
  • 多个标签键之间用&分隔。
  • 不能以 volc:sys:开头,包括任意大小写形式。
  • 长度取值范围为1~128字符,允许输入各国语言文字、数字、空格( )、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、中划线(-)和@(@)。
  • 若标签键开头或结尾存在空格,系统会自动为其去除。

说明

同一资源的标签键不允许重复。

Tags.N.Value

String

Tags.1.Value=value1&Tags.2.Value=value2

用户标签的标签值。

  • 参数 - N:表示标签值的序号,取值范围:1~50。
  • 多个标签值之间用&分隔。
  • 长度取值范围为0~256字符,不填默认为空。
  • 允许输入各国语言文字、数字、空格( )、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、中划线(-)和@(@)。
  • 大小写敏感。
  • 若标签值开头或结尾存在空格,系统会自动为其去除。

说明

若传入该参数,则必须先传入Tags.N.Key

ClientToken

String

333456899ff****

保证请求幂等性。由客户端自动生成一个参数值,确保不同请求间该参数值唯一,避免当调用API超时或服务器内部错误时,客户端多次重试导致重复性操作。取值:

  • 仅支持ASCII字符,且不能超过64个字符。

返回数据

参数名称
类型
示例值
描述
RequestIdString2021062415303301022514515207C4****请求ID。
NatGatewayIdStringngw-2feq5xhimd88w59gp686****新创建的NAT网关实例ID。

请求示例

GET /?Action=CreateNatGateway&Version=2020-04-01&NatGatewayName=nat-1&Spec=Small&BillingType=2&VpcId=vpc-2feypfmenesqo59gp67yz****&SubnetId=subnet-2feypga30rgg059gp67ag**** HTTP/1.1
Host: open.volcengineapi.com
Service: natgateway
Region: cn-beijing

返回示例

{
    "ResponseMetadata": {
        "RequestId": "2021062415303301022514515207C4****",
        "Action": "CreateNatGateway",
        "Version": "2020-04-01",
        "Service": "natgateway",
        "Region": "cn-beijing"
    },
    "Result":{
        "RequestId": "2021062415303301022514515207C4****",
        "NatGatewayId": "ngw-2feq5xhimd88w59gp686****"
    }
}

错误码

公共错误码,请参见 公共错误码 。

HttpCode
错误码
错误信息
描述
400IdempotentParameterMismatchArguments on this idempotent request are inconsistent with arguments used in previous request(s).此幂等请求的参数与前一个请求中使用的参数不一致。
400InsufficientIpInSubnetThe specified subnet does not contain enough free private IP addresses to fulfill your request.指定子网下可用IP不足。
400InvalidBillingType.MalformedThe specified billing type is malformed.指定的计费类型不合法。
400InvalidDescription.MalformedThe specified description is malformed.Ensure the maximum length of description is 255.指定的描述格式不合法。描述长度不能超过255个字符。
400InvalidDescription.MalformedThe specified description is malformed.指定的描述格式不合法。请修复描述格式后重试。
400InvalidMonthPeriod.MalformedThe specified monthly period is malformed. Monthly period only supports 1~9, 12, 24, 36.指定的包年包月按月购买时长不合法。包年包月按月购买时长只支持1~9, 12, 24, 36月。
400InvalidName.MalformedThe specified name is malformed.Ensure the maximum length of name is 128.指定的名称格式不合法。名称长度不能超过128个字符。
400InvalidName.MalformedThe specified name is malformed.指定的名称格式不合法。请修复名称格式后重试。
400InvalidNatGateway.NoSubnetInVpcThe specified VPC has no subnet. NAT gateway cannot be created.指定的VPC没有子网,无法创建NAT网关。
400InvalidNatGateway.PreOrderCreate preorder for nat gateway failed.创建NAT网关的配置单失败。
400InvalidNatGatewayDefaultRoute.ConflictA default route already exists in specified VPC, NAT gateway cannot be created.指定的VPC里已经存在默认路由,无法创建NAT网关。
400InvalidNatGatewaySpec.MalformedThe specified NAT spec is malformed.指定的NAT网关规格不支持。
400InvalidParameter.ClientTokenMalformedThe specified parameter ClientToken is malformed.指定的参数ClientToken格式不合法。参数长度不能超过64个ASCII字符。
400InvalidPeriodUnit.MalformedThe specified period unit is malformed. Pre billing period unit can only be Month or Year.指定的包年包月类型时长单位不合法。包年包月类型时长单位只能为月或年。
400InvalidSubnet.VpcMismatchThe specified subnet is not in the specified VPC.指定的子网不在指定的VPC中。
400InvalidTag.DisorderThe specified index order of tag is malformed.指定标签的索引顺序参数格式不合法。
400InvalidTagKey.MalformedThe specified parameter tag key is invalid.标签键不合法。
400InvalidTagValue.MalformedThe specified parameter tag value is invalid.标签值不合法。
400InvalidYearPeriod.MalformedThe specified yearly period is malformed. Yearly period only supports 1~3.指定的包年包月按年购买时长不合法。包年包月按年购买时长只支持1~3年。
400InvalidZone.NotSupportedThe specified Availability Zone does not support Nat Gateways.指定子网所在可用区未部署NAT网关资源。
400LimitExceeded.TagsYou've reached the limit on the number of tags that you can operate at one time.已达到单次可操作标签数量的上限。
400OrderErrorFailed to create an order in one step.创建订单并支付失败。
400QuotaExceeded.EniENI number exceeded quota.已达到当前账户在一个地域可创建网卡数量上限。
400QuotaExceeded.NatGatewayNAT gateways number of the VPC exceeded quota.已达到一个VPC可创建的NAT网关的数量上限。
400QuotaExceeded.RouteEntryRoute entry of a route table number exceeded quota.已达到一个路由表可创建路由条目的上限。
400QuotaExceeded.SecurityGroupSecurity group number exceeded quota.已达到当前账户在一个地域可创建安全组数量上限。
400UnsupportedOperationThe request on the specified instance is denied due to the account in arrears status.因账户处于欠费状态,对于该实例的操作请求被拒绝。
400UnsupportedOperationThe request on the specified instance is denied due to the account balance and available vouchers are less than 100 yuan in total.因账户余额及可用代金券共不足100元,对于该实例的操作请求被拒绝。
404InvalidProject.NotFoundThe specified project does not exist.指定的项目不存在。
404InvalidSubnet.NotFoundThe specified subnet does not exist.指定的子网不存在。
404InvalidVpc.NotFoundThe specified VPC does not exist.指定的VPC不存在。
412IdempotentProcessingThe request uses the same client token as a previous one that is still in process.幂等请求处理中。