Deletes a specified Internet NAT gateway or a Virtual Private Cloud (VPC) NAT gateway.

Usage notes

  • DeleteNatGateway is an asynchronous operation. After you make a request, the ID of the request is returned but the 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 Deleting state, the NAT gateway is being deleted. In this case, you can query the NAT gateway but you cannot perform other operations.
    • If the NAY gateway cannot be found, the NAT gateway is deleted.

      After you delete a NAT gateway, you cannot restore the NAT gateway. Proceed with caution.

  • You cannot repeatedly call the DeleteNatGateway operation to delete a NAT gateway within the specified period of time.

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 the 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.

RegionId String Yes cn-hangzhou

The ID of the region where the NAT gateway is deployed.

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

NatGatewayId String Yes ngw-bp1uewa15k4iy5770****

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

Force Boolean No false

Specifies whether to forcefully delete the NAT gateway. Valid values:

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

http(s)://[Endpoint]/?Action=DeleteNatGateway
&RegionId=cn-hangzhou
&NatGatewayId=ngw-bp1uewa15k4iy5770****
&Force=false
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

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

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

HttpCode Error code Error message Description
400 DependencyViolation.BandwidthPackages There are BandwidthPackages on specified NatGateway not deleted. The error message returned because one or more NAT bandwidth plans are associated with the NAT gateway. Disassociate all NAT bandwidth plans from the NAT gateway and try again.
400 IncorrectStatus.NatIp The status of %s [%s] is incorrect. The error message returned because the status of the NAT IP address is invalid.
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 value of the NatGatewayId parameter is valid.

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