All Products
Search
Document Center

Elastic Compute Service:CreateNatGateway

Last Updated:Apr 16, 2026

CreateNatGateway

Note

This API has been deprecated. We recommend migrating to Vpc(2016-04-28) - CreateNatGateway for enhanced functionality and continued support. While the deprecated API remains temporarily accessible, no further updates or bug fixes will be provided.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

vpc:CreateNatGateway

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The ID of the region in which to create the nat gateway.

VpcId

string

Yes

The ID of the VPC in which to create the nat gateway.

Name

string

No

A name for the nat gateway.

The name must be 2 to 128 characters in length. It must start with a letter or a Chinese character but cannot start with http:// or https://.

Description

string

No

A description of the nat gateway.

The description must be 2 to 256 characters in length. It must start with a letter or a Chinese character but cannot start with http:// or https://.

ClientToken

string

No

A client token to ensure the idempotence of the request.

This token is client-generated and must be unique for each request. The token can contain only ASCII characters and cannot exceed 64 characters in length.

BandwidthPackage

array<object>

Yes

Configurations for the bandwidth packages to create and associate with the nat gateway.

object

No

The configuration for a bandwidth package.

Bandwidth

integer

No

The peak bandwidth for the EIPs in the bandwidth package. Unit: Mbit/s.

Zone

string

No

The ID of the zone in which to create the EIPs. If you do not specify a zone, the system randomly selects one.

IpCount

integer

No

The number of EIPs to create in the bandwidth package. Valid values: 1 to 10.

Response elements

Element

Type

Description

Example

object

The response parameters.

NatGatewayId

string

The ID of the NAT gateway.

RequestId

string

The ID of the request.

ForwardTableIds

object

The IDs of the forwarding tables.

ForwardTableId

array

The list of forwarding table IDs.

string

The ID of a forwarding table.

BandwidthPackageIds

object

The IDs of the EIP bandwidth plans.

BandwidthPackageId

array

The list of EIP bandwidth plan IDs.

string

The ID of an EIP bandwidth plan.

Examples

Success response

JSON format

{
  "NatGatewayId": "",
  "RequestId": "",
  "ForwardTableIds": {
    "ForwardTableId": [
      ""
    ]
  },
  "BandwidthPackageIds": {
    "BandwidthPackageId": [
      ""
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidVPCStatus vpc incorrect status. The specified VPC state is invalid.
400 InvalidNatGatewayName.MalFormed NatGateway name is not valid. The specified NAT gateway name is invalid.
400 InvalidNatGatewayDescription.MalFormed NatGateway description is not valid. The specified NAT gateway description is invalid.
400 MissingParameter.BandwidthPackage only support one BandwidthPackage be created with NatGateway.
400 OperationDenied The user cannot allow to create natgw, please call PD to authorize
400 RouterEntryConflict.Duplicated A route entry already exists, which CIDR is '0.0.0.0/0'
400 MissingParameter Miss mandatory parameter. Required parameters must be specified.
400 QuotaExceeded.BandwidthPackageIps The specified ipCount exceeded quota. The specified number of IP addresses exceeds the upper limit.
400 AllocateIpFailed Alloc bandwidthPackage ips failed, maybe no available ip.
400 ParameterIllegal ipCount,bandwidth parameter invalid
400 ZONE_NO_AVAILABLE_IP The Zone have no available ip. No IP addresses are available in the specified zone.
400 InvalidNatGatewayId.NotFound The NatGatewayId not exist.
400 InvalidParameter.Spec.ValueNotSupported The specified Spec is not valid.
400 COMMODITY.INVALID_COMPONENT The instance component is invalid.
400 OperationUnsupported.MultiNatGateway More than one natGateway per vpc is unsupported.
400 VswitchStatusError The VSwitch is creating .
400 Forbidden.CheckEntryRuleQuota Route entry quota rule check error. An error occurred when the system was checking the quota of route entries.
400 OperationFailed.UnpaidBillsExist The account has unpaid bills. Please pay your overdue bill first.
400 IncorrectStatus.RouteEntry Specified routeEntry status error.
400 IncorrectStatus.RouteTableStatus %s
400 TaskConflict The operation is too frequent, please wait a moment and try again.
400 OperationFailed.TokenVerfiy Token verify failed.
400 IllegalParam.Name The specified Name is invalid, shorter than 2 characters.
500 OrderError.NatGateway The Account failed to create order.
404 InvalidRegionId.NotFound The specified RegionId does not exist in our records. The specified RegionId parameter does not exist. Check whether the service is available in the specified region.
404 InvalidVpcId.NotFound Specified value of VpcId is not found in our record. The specified VPC ID does not exist.
404 InvalidZoneId.NotFound Specified value of ZoneId is not exists. The specified zone ID does not exist.
404 VPC_ONLY_CAN_CREATE_ONE_NAT_GATEWAY NatGateway in one vpc support only one.
404 OperationFailed.CrateEntryTimeOut Operation failed because create custom routeEntry timeout.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.