All Products
Search
Document Center

Virtual Private Cloud:DeleteNatGateway

Last Updated:Aug 29, 2024

Deletes a specified Internet NAT gateway.

Operation description

Description

  • DeleteNatGateway is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call the DescribeNatGateways to query the status of the task.

    • 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 NAT 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.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
vpc:DeleteNatGatewaydelete
  • NatGateway
    acs:vpc:{#regionId}:{#accountId}:natgateway/{#natgatewayid}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the NAT gateway.

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

cn-hangzhou
NatGatewayIdstringYes

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

ngw-bp1uewa15k4iy5770****
ForcebooleanNo

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

  • true 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.
  • false(default): no If you set the value to false:

    • If the NAT gateway is associated with a NAT bandwidth plan, disassociate 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.
false

Response parameters

ParameterTypeDescriptionExample
object

The request ID.

RequestIdstring

The request ID.

0ED8D006-F706-4D23-88ED-E11ED28DCAC0

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
400DependencyViolation.VpcEndpointServiceThe specified resource of %s depends on %s, so the operation cannot be completed.You cannot perform the operation because the NAT gateway is associated with an endpoint service.
400DependencyViolation.FullNatEntryThe specified resource of %s depends on %s, so the operation cannot be completed.-
400DependencyViolation.RouterEntryThe specified resource of %s depends on %s, so the operation cannot be completed.You cannot perform the operation because the NAT gateway is associated with a route entry.
400DependencyViolation.BandwidthPackagesThere are BandwidthPackages on specified NatGateway not deleted.NAT service plans are associated with the NAT gateway. Disassociate the NAT service plans from the NAT gateway and try again.
400DependencyViolation.EIPSThere are Eips on specified NatGateway, please unbind it first.An EIP is associated with the NAT gateway. Disassociate the EIP from the NAT gateway first.
400Forbidden.PrePaidNatGatewayThe specified NatGateway is PrePaid.-
400InvalidOperation.DeletionProtectionThe instance cannnot delete because of deletion protecion.-
400DependencyViolation.SnatEntryThe specified resource of %s depends on %s, so the operation cannot be completed.-
400IncorrectStatus.SnatEntryThe status of %s [%s] is incorrect.-
400DependencyViolation.ForwardEntryThe specified resource of %s depends on %s, so the operation cannot be completed.-
400IncorrectStatus.ForwardEntryThe status of %s [%s] is incorrect.The DNAT entry to be deleted is in an invalid state.
400DependencyViolation.NatIpThe specified resource of %s depends on %s, so the operation cannot be completed.You cannot perform the operation because the NAT gateway is associated with a NAT IP address.
400IncorrectStatus.NatIpThe status of %s [%s] is incorrect.The status of NatIp is incorrect.
400DependencyViolation.NatIpCidrThe specified resource of %s depends on %s, so the operation cannot be completed.You cannot perform the operation because the NAT gateway is associated with a NAT CIDR block.
404INSTANCE_NOT_EXISTSInstance not exists.-
404InvalidRegionId.NotFoundThe specified RegionId does not exist in our records.The specified region ID does not exist.
404InvalidNatGatewayId.NotFoundThe specified NatGatewayId does not exist in our records.The value of the NatGatewayId parameter is invalid.
404IncorrectStatus.NatGateway%s-
404ResourceNotFound.NatGatewayThe specified resource of %s is not found.-

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-01-18The Error code has changedView Change Details
2023-12-20The Error code has changedView Change Details
2023-07-24API Description Update. The Error code has changedView Change Details