Deletes a specified Internet NAT gateway.

Description

DeleteNatGateway is an asynchronous operation. After you make a request, the ID of the request is returned but the specified Internet NAT gateway is not deleted. The system deletes the NAT gateway in the background. You can call the DescribeNatGateways to query the status of a NAT gateway:

  • If a NAT gateway is in the Modifying state, the NAT gateway is being upgraded. In this case, you can only perform query operations.
  • If no NAT gateway is returned in the response, the NAT gateway is deleted.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates a sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DeleteNatGateway

The operation that you want to perform. Set the value to DeleteNatGateway.

NatGatewayId String Yes ngw-bp1uewa15k4iy5770****

The ID of the Internet NAT gateway that you want to delete.

RegionId String Yes cn-hangzhou

The region ID of the Internet NAT gateway.

You can call the DescribeRegions operation to query the most recent region list.

Force Boolean No false

Specifies whether to forcibly delete the Internet NAT gateway. Valid values:

  • true: yes If you set the value to true:
    • If the Internet NAT gateway has SNAT entries, the system automatically deletes them.
    • If the Internet NAT gateway has DNAT entries, the system automatically deletes them.
    • If the Internet NAT gateway is associated with an elastic IP address (EIP), the system automatically disassociates it from the NAT gateway.
    • If the Internet NAT gateway is associated with a NAT bandwidth plan, the system automatically disassociates the NAT bandwidth plan.
  • false(default): no If you set the value to false:
    • If the Internet NAT gateway is associated with a NAT bandwidth plan, disassociate the NAT bandwidth plan first.
    • If the Internet NAT gateway has SNAT entries, delete them first.
    • If the Internet NAT gateway has DNAT entries, delete them first.
    • If the Internet NAT gateway is associated with an EIP, disassociate the EIP from the NAT gateway first.

Response parameters

Parameter Type Example Description 
RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

The ID of the request.

Examples

Sample requests

https://vpc.aliyuncs.com/?Action=DeleteNatGateway
&NatGatewayId=ngw-bp1uewa15k4iy5770****
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

<DeleteNatGatewayResponse>
      <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
</DeleteNatGatewayResponse>

JSON format

{ 
    "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0"
}

Error codes

HttpCode Error code Error message Description
404 InvalidRegionId.NotFound The specified RegionId does not exist in our records. The error message returned because the specified region ID does not exist.
404 InvalidNatGatewayId.NotFound The specified NatGatewayId does not exist in our records. The error message returned because the specified NAT gateway ID does not exist. Check whether the NAT gateway ID is valid.
400 DependencyViolation.BandwidthPackages There are BandwidthPackages on specified NatGateway not deleted. The error message returned because one or more NAT service plans are associated with the NAT gateway. Disassociate all NAT service plans from the NAT gateway and try again.

For a list of error codes, visit the API Error Center.