全部产品
Search
文档中心

NAT 网关:DeleteNatGateway - 删除指定的NAT网关

更新时间:Aug 05, 2026

调用DeleteNatGateway接口删除指定的公网NAT网关。

接口说明

DeleteNatGateway 接口属于异步接口,即系统会先返回一个请求 ID,但该 NAT 网关实例并未删除完成,系统后台的删除任务仍在进行。您可以调用 DescribeNatGateways 查询 NAT 网关的状态:

  • 当 NAT 网关处于 Deleting 状态时,表示 NAT 网关正在删除中,在该状态下,您只能执行查询操作,不能执行其他操作。

  • 当查询不到该 NAT 网关实例时,表示 NAT 网关删除完成。

说明

删除 NAT 网关操作不可恢复,请您谨慎操作。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

vpc:DeleteNatGateway

delete

*NatGateway

acs:vpc:{#regionId}:{#accountId}:natgateway/{#natgatewayid}

请求参数

名称

类型

必填

描述

示例值

RegionId

string

NAT 网关所在的地域 ID。

您可以通过调用 DescribeRegions 接口获取地域 ID。

cn-hangzhou

NatGatewayId

string

要删除的 NAT 网关的实例 ID。

ngw-bp1uewa15k4iy5770****

Force

boolean

是否强制删除 NAT 网关,取值:

  • true:强制删除。当取值为 true 时,说明如下:

    • 如果 NAT 网关有 SNAT 规则,系统会自动帮您删除 SNAT 规则。

    • 如果 NAT 网关有 DNAT 规则,系统会自动帮您删除 DNAT 规则。

    • 如果 NAT 网关有绑定 EIP,系统会自动帮您解绑。

    • 如果 NAT 网关有未删除的 NAT 带宽包,系统会自动帮您删除 NAT 带宽包。

  • false(默认值):不强制删除。当取值为 false 时,说明如下:

    • 如果 NAT 网关有未删除的 NAT 带宽包,请先删除 NAT 带宽包。

    • 如果 NAT 网关有 SNAT 规则,请先删除 SNAT 规则。

    • 如果 NAT 网关有 DNAT 规则,请先删除 DNAT 规则。

    • 如果 NAT 网关有绑定 EIP,请先解绑 EIP。

false

返回参数

名称

类型

描述

示例值

object

请求 ID。

RequestId

string

请求 ID。

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

示例

正常返回示例

JSON格式

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

错误码

HTTP status code

错误码

错误信息

描述

400 DependencyViolation.VpcEndpointService The specified resource of %s depends on %s, so the operation cannot be completed. NAT有依赖的终端节点服务,所以此操作不能进行
400 DependencyViolation.FullNatEntry The specified resource of %s depends on %s, so the operation cannot be completed.
400 DependencyViolation.RouterEntry The specified resource of %s depends on %s, so the operation cannot be completed. NAT有依赖的路由条目,所以此操作不能进行
400 DependencyViolation.BandwidthPackages There are BandwidthPackages on specified NatGateway not deleted.
400 DependencyViolation.EIPS There are Eips on specified NatGateway, please unbind it first. 指定的NAT网关已绑定了弹性公网IP,请先将其从NAT网关解绑。
400 Forbidden.PrePaidNatGateway The specified NatGateway is PrePaid.
400 InvalidOperation.DeletionProtection The instance cannnot delete because of deletion protecion.
400 DependencyViolation.SnatEntry The specified resource of %s depends on %s, so the operation cannot be completed. NatIp或Ipv4Prefix存在关联的SnatEntry,删除操作无法继续,请删除依赖的Snat后再重新删除。
400 IncorrectStatus.SnatEntry The status of %s [%s] is incorrect.
400 DependencyViolation.ForwardEntry The specified resource of %s depends on %s, so the operation cannot be completed.
400 IncorrectStatus.ForwardEntry The status of %s [%s] is incorrect. 要删除的DNAT条目实例状态不对
400 DependencyViolation.NatIp The specified resource of %s depends on %s, so the operation cannot be completed. 有依赖的NAT IP,所以此操作不能进行
400 IncorrectStatus.NatIp The status of %s [%s] is incorrect. NatIp当前状态不正确。
400 DependencyViolation.NatIpCidr The specified resource of %s depends on %s, so the operation cannot be completed. NAT有依赖的NAT IP CIDR,所以此操作不能进行
400 IncorrectStatus.NatGateway The NatGateway instance is being deleted and needs to wait until the process is complete. NAT网关实例正在被删除,无法重复删除,需要等待删除过程完成。
400 IncorrectStatus.RouterEntry The status of %s [%s] is incorrect. RouterEntry当前状态不正确。
400 IncorrectStatus.VSwitch The specified vSwitch status is invalid. 虚拟交换机状态异常。
404 INSTANCE_NOT_EXISTS Instance not exists.
404 InvalidRegionId.NotFound The specified RegionId does not exist in our records.
404 InvalidNatGatewayId.NotFound The specified NatGatewayId does not exist in our records.
404 ResourceNotFound.NatGateway The specified resource of %s is not found.

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情