帮助文档 Logo
平台使用
阿里云
百度云
移动云
智算服务
教育生态
登录 →
帮助文档 Logo
平台使用 阿里云 百度云 移动云 智算服务 教育生态
登录
  1. 首页
  2. 阿里云
  3. 云服务器 ECS
  4. 开发参考
  5. API参考(ECS)
  6. API目录
  7. 安全组
  8. RevokeSecurityGroupEgress - 删除出方向安全组规则

RevokeSecurityGroupEgress - 删除出方向安全组规则

  • 安全组
  • 发布于 2025-04-01
  • 0 次阅读
文档编辑
文档编辑

本接口用于删除指定安全组内的一条或多条出方向安全组规则。

接口说明

注意 阿里云已于 2024 年 7 月 8 日对该接口进行了校验规则调整。当删除不存在的安全组规则时,从返回成功调整为返回错误码:“InvalidSecurityGroupRule.RuleNotExist“。请您及时做好错误码兼容,避免影响线上业务。
该接口有两种传参方式来删除安全组规则:

  • 通过指定安全组规则 ID 参数删除规则(推荐)。

    • 如果指定的安全组规则 ID 不存在,会报异常。
  • 通过指定 Permissions 参数删除规则。

    • 如果匹配的安全组规则不存在,此次调用成功,但不会删除规则。
    • 删除一条安全组规则必要的相关参数:
      • 目的端设置:选择 DestCidrIp(IPv4 地址)、Ipv6DestCidrIp(IPv6 地址)、DestPrefixListId(前缀列表 ID)、DestGroupId(目的端安全组)中的一项。
      • 目的端口范围:PortRange。
      • 协议类型:IpProtocol。
      • 权限策略:Policy。
说明 不支持同时设置安全组规则 ID 和 Permissions 参数。

请求示例

  • 根据安全组规则 ID 删除。
"SecurityGroupId":"sg-bp67acfmxazb4p****", //设置安全组 ID
"SecurityGroupRuleId":["sgr-bpdfmk****","sgr-bpdfmg****"] //设置安全组规则 ID
  • 根据 IP 地址段删除。
"SecurityGroupId":"sg-bp67acfmxazb4ph***",
"Permissions":[
  {
    "IpProtocol":"TCP", //设置协议类型
    "DestCidrIp":"10.0.0.0/8", //设置目的端 IP 地址段
    "PortRange":"22/22", //设置目的端口范围
    "Policy":"accept" // 设置访问策略
  }
]
  • 根据目的端安全组删除。
"SecurityGroupId":"sg-bp67acfmxazb4ph***",
"Permissions":[
  {
    "DestGroupId":"sg-bp67acfmxa123b****", //设置目的端安全组 ID
    "IpProtocol":"TCP",
    "PortRange":"22/22",
    "Policy":"accept"
  }
]
  • 根据指定前缀列表删除。
"SecurityGroupId":"sg-bp67acfmxazb4ph***",
"Permissions":[
  {
    "IpProtocol":"TCP",
    "DestPrefixListId":"pl-x1j1k5ykzqlixdcy****", //设置目的端前缀列表 ID
    "PortRange":"22/22",
    "Policy":"accept",
  }
]

调试

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

调试

授权信息

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

  • 操作:是指具体的权限点。
  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:
    • 对于必选的资源类型,用前面加 * 表示。
    • 对于不支持资源级授权的操作,用全部资源表示。
  • 条件关键字:是指云产品自身定义的条件关键字。
  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作访问级别资源类型条件关键字关联操作
ecs:RevokeSecurityGroupEgressdelete
*SecurityGroup
acs:ecs:{#regionId}:{#accountId}:securitygroup/{#securitygroupId}
  • ecs:tag
无

请求参数

名称类型必填描述示例值
RegionIdstring是

安全组所属地域 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。

cn-hangzhou
ClientTokenstring否

保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符,且不能超过 64 个字符。更多详情,请参见如何保证幂等性。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E
SecurityGroupIdstring是

安全组 ID。

sg-bp67acfmxazb4p****
SecurityGroupRuleIdarray否

安全组规则 ID 数组。数组长度:0~100。

string否

安全组规则 ID。

说明 通过安全组规则 ID 删除时,该参数必填。
sgr-bp67acfmxa123b***
Permissionsarray<object>否

安全组规则数组。数组长度:0~100。

object否

安全组规则。

Policystring否

访问权限。取值范围:

  • accept:接受访问。
  • drop:拒绝访问,不返回拒绝信息,表现为发起端请求超时或者无法建立连接的类似信息。

默认值:accept。

accept
Prioritystring否

安全组规则优先级。数字越小,代表优先级越高。取值范围:1~100。

默认值:1。

1
IpProtocolstring否

协议类型。取值不区分大小写。取值范围:

  • TCP。
  • UDP。
  • ICMP。
  • ICMPv6。
  • GRE。
  • ALL:支持所有协议。
TCP
DestCidrIpstring否

需要撤销访问权限的目的端 IPv4 CIDR 地址块。支持 CIDR 格式和 IPv4 格式的 IP 地址范围。

10.0.0.0/8
Ipv6DestCidrIpstring否

需要撤销访问权限的目的端 IPv6 CIDR 地址块。支持 CIDR 格式和 IPv6 格式的 IP 地址范围。

说明 仅在支持 IPv6 的 VPC 类型 ECS 实例上有效,且该参数与DestCidrIp参数不可同时设置。
2001:db8:1233:1a00::***
DestGroupIdstring否

需要撤销访问权限的目的端安全组 ID。

  • 至少设置一项DestGroupId或者DestCidrIp、Ipv6DestCidrIp或DestPrefixListId参数中的一项。
  • 如果指定了DestGroupId没有指定参数DestCidrIp,则参数NicType取值只能为 intranet。
  • 如果同时指定了DestGroupId和DestCidrIp,则默认以DestCidrIp为准。

您需要注意:

  • 企业安全组不支持授权安全组访问。
  • 普通安全组支持授权的安全组数量最多为 20 个。
sg-bp67acfmxa123b****
DestPrefixListIdstring否

需要撤销访问权限的目的端前缀列表。您可以调用 DescribePrefixLists 查询可以使用的前缀列表 ID。

注意事项:

  • 安全组的网络类型为经典网络时,不支持设置前缀列表。关于安全组以及前缀列表使用限制的更多信息,请参见安全组使用限制。
  • 当您指定了DestCidrIp、Ipv6DestCidrIp、DestGroupId参数中的一个时,将忽略该参数。
pl-x1j1k5ykzqlixdcy****
PortRangestring否

安全组开放的各协议相关的目的端口范围。取值范围:

  • TCP/UDP 协议:取值范围为 1~65535。使用正斜线(/)隔开起始端口和终止端口。例如:1/200。
  • ICMP 协议:-1/-1。
  • GRE 协议:-1/-1。
  • ALL:-1/-1。
22/22
SourceCidrIpstring否

源端 IPv4 CIDR 地址段。支持 CIDR 格式和 IPv4 格式的 IP 地址范围。

用于支持五元组规则,请参见安全组五元组规则。

10.0.0.0/8
Ipv6SourceCidrIpstring否

源端 IPv6 CIDR 地址段。支持 CIDR 格式和 IPv6 格式的 IP 地址范围。

用于支持五元组规则,请参见安全组五元组规则。

说明 仅在支持 IPv6 的 VPC 类型 ECS 实例上有效,且该参数与DestCidrIp参数不可同时设置。
2001:db8:1234:1a00::***
SourcePortRangestring否

安全组开放的各协议相关的源端端口范围。取值范围:

  • TCP/UDP 协议:取值范围为 1~65535。使用正斜线(/)隔开起始端口和终止端口。例如:1/200。
  • ICMP 协议:-1/-1。
  • GRE 协议:-1/-1。
  • ALL:-1/-1。

用于支持五元组规则,请参见安全组五元组规则。

22/22
DestGroupOwnerAccountstring否

撤销跨账户授权的安全组规则时,目的端安全组所属的阿里云账户。

  • 如果DestGroupOwnerAccount及DestGroupOwnerId均未设置,则认为是撤销您其他安全组的访问权限。
  • 如果已经设置参数DestCidrIp,则参数DestGroupOwnerAccount无效。
Test@aliyun.com
DestGroupOwnerIdstring否

撤销跨账户授权的安全组规则时,目的端安全组所属的阿里云账户。

  • 如果DestGroupOwnerId及DestGroupOwnerAccount均未设置,则认为是撤销您其他安全组的访问权限。
  • 如果您已经设置参数DestCidrIp,则参数DestGroupOwnerId无效。
12345678910
NicTypestring否

经典网络类型安全组规则的网卡类型。取值范围:

  • internet:公网网卡。
  • intranet:内网网卡。

专有网络 VPC 类型安全组规则无需设置网卡类型,默认为 intranet,只能为 intranet。

撤销安全组之间授权规则,即指定了SourceGroupId参数时,只能为 intranet。

默认值:internet。

intranet
Descriptionstring否

安全组规则的描述。长度为 1~512 个字符。

This is description.
Policydeprecatedstring否

已废弃。请使用Permissions.N.Policy来设置访问权限。

accept
Prioritydeprecatedstring否

已废弃。请使用Permissions.N.Priority来指定规则优先级。

1
IpProtocoldeprecatedstring否

已废弃。请使用Permissions.N.IpProtocol来指定协议类型。

TCP
DestCidrIpdeprecatedstring否

已废弃。请使用Permissions.N.DestCidrIp来指定目的端 IPv4 CIDR 地址块。

10.0.0.0/8
Ipv6DestCidrIpdeprecatedstring否

已废弃。请使用Permissions.N.Ipv6DestCidrIp来指定目的端 IPv6 CIDR 地址块。

2001:db8:1233:1a00::***
DestGroupIddeprecatedstring否

已废弃。请使用Permissions.N.DestGroupId来指定目的端安全组 ID。

sg-bp67acfmxa123b****
DestPrefixListIddeprecatedstring否

已废弃。请使用Permissions.N.DestPrefixListId来指定源端前缀列表 ID。

pl-x1j1k5ykzqlixdcy****
PortRangedeprecatedstring否

已废弃。请使用Permissions.N.PortRange来指定端口范围。

22/22
SourceCidrIpdeprecatedstring否

已废弃。请使用Permissions.N.SourceCidrIp来指定源端 IPv4 CIDR 地址段。

10.0.0.0/8
Ipv6SourceCidrIpdeprecatedstring否

已废弃。请使用Permissions.N.Ipv6SourceCidrIp来指定源端 IPv6 CIDR 地址段。

2001:db8:1234:1a00::***
SourcePortRangedeprecatedstring否

已废弃。请使用Permissions.N.SourcePortRange来指定源端端口范围。

22/22
DestGroupOwnerAccountdeprecatedstring否

已废弃。请使用Permissions.N.DestGroupOwnerAccount来指定目的端安全组所属的阿里云账户。

Test@aliyun.com
DestGroupOwnerIddeprecatedlong否

已废弃。请使用Permissions.N.DestGroupOwnerId来指定目的端安全组所属的阿里云账户 ID。

12345678910
NicTypedeprecatedstring否

已废弃。请使用Permissions.N.NicType来指定网卡类型。

intranet
Descriptiondeprecatedstring否

已废弃。请使用Permissions.N.Description来指定规则的描述。

This is description.

返回参数

名称类型描述示例值
object
RequestIdstring

请求 ID。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

示例

正常返回示例

JSON格式

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}

错误码

HTTP status code错误码错误信息描述
400InvalidIpProtocol.ValueNotSupportedThe parameter IpProtocol must be specified with case insensitive TCP, UDP, ICMP, GRE or All.协议类型只能是TCP、UDP、ICMP、GRE或者All。
400InvalidIpPortRange.MalformedThe specified parameter PortRange is not valid.IP协议相关的端口号范围格式不正确。
400InvalidDestCidrIp.sMalformedThe specified parameter DestCidrIp is not valid.指定的参数 DestCidrIp 不合法。
400MissingParameterThe input parameter DestGroupId or DestCidrIp cannot be both blank.参数 DestGroupId 和 DestCidrIp 不得为空。
400InvalidPolicy.MalformedThe specified parameter %s is not valid.指定的授权策略参数Policy不合法。
400InvalidNicType.ValueNotSupportedThe specified parameter %s is not valid.指定的网卡类型参数NicType不合法。
400InvalidDestGroupId.MismatchSpecified security group and destination group are not in the same VPC.指定的安全组和目标组不在同一个 VPC 下。
400InvalidDestCidrIp.MalformedThe specified parameter DestCidrIp is not valid.指定的 DestCidrIp 无效,请您检查该参数是否正确。
400MissingParameter.DestOne of the parameters DestCidrIp, Ipv6DestCidrIp, DestGroupId or DestPrefixListId in %s must be specified.请指定参数DestCidrIp,Ipv6DestCidrIp,DestGroupId或DestPrefixListId中的至少一个。
400InvalidParam.PortRangeThe specified parameter %s is not valid. It should be two integers less than 65535 in ?/? format.端口范围不合法,应为斜线分隔两个整数的格式。
400InvalidIpProtocol.ValueNotSupportedThe parameter %s must be specified with case insensitive TCP, UDP, ICMP, GRE or All.协议Protocol字段不合法,应指定大小写不敏感的TCP,UDP,ICMP,GRE或All。
400InvalidPriority.MalformedThe parameter Priority is invalid.指定的参数 Priority 无效。
400InvalidPriority.ValueNotSupportedThe specified parameter %s is invalid.指定的优先级参数Priority不合法。
400InvalidParam.SourceIpThe Parameters SourceCidrIp and Ipv6SourceCidrIp in %s cannot be set at the same time.参数SourceCidrIp和Ipv6SourceCidrIp不能被同时设置。
400InvalidParam.DestIpThe Parameters DestCidrIp and Ipv6DestCidrIp in %s cannot be set at the same time.参数DestCidrIp和Ipv6DestCidrIp不能被同时设置。
400InvalidParam.Ipv6DestCidrIpThe specified parameter %s is not valid.指定的参数Ipv6DestCidrIp不合法。
400InvalidParam.Ipv6SourceCidrIpThe specified parameter %s is not valid.指定的参数Ipv6SourceCidrIp不合法。
400InvalidParam.Ipv4ProtocolConflictWithIpv6AddressIPv6 address cannot be specified for IPv4-specific protocol.IPv4协议不能指定IPv6地址。
400InvalidParam.Ipv6ProtocolConflictWithIpv4AddressIPv4 address cannot be specified for IPv6-specific protocol.IPv6协议不能指定IPv4地址。
400InvalidParameter.Ipv6CidrIpThe specified Ipv6CidrIp is not valid.指定的Ipv6CidrIp参数不合法。
400InvalidGroupAuthParameter.OperationDeniedThe security group can not authorize to enterprise level security group.安全组不能授权给企业级安全组。
400InvalidSecurityGroupId.MalformedThe specified parameter SecurityGroupId is not valid.指定的参数 SecurityGroupId 无效。
400InvalidPortRange.MalformedThe specified parameter PortRange must set.参数PortRange必须被设置。
400InvalidSourcePortRange.MalformedThe specified parameter SourcePortRange is not valid.指定的参数 SourcePortRange 无效。
400InvalidSecurityGroupDiscription.MalformedThe specified security group rule description is not valid.指定的安全组规则描述不合法。
400NotSupported.ClassicNetworkPrefixListThe prefix list is not supported when the network type of security group is classic.安全组的网络类型为经典网络,不支持前缀列表。
400InvalidParam.SourceCidrIpThe specified parameter %s is not valid.指定的参数SourceCidrIp不合法。
400InvalidParam.SourceCidrIpThe specified param SourceCidrIp is not valid.参数SourceCidrIp不合法。
400InvalidParam.DestCidrIpThe specified parameter %s is not valid.指定的参数DestCidrIp不合法。
400InvalidParam.DestCidrIpThe specified parameter DestCidrIp is invalid.指定的参数“DestCidrIp”无效。
400InvalidParam.PermissionsThe specified parameter Permissions cannot coexist with other parameters.指定的参数Permissions不能与其他参数同时存在。
400InvalidParam.DuplicatePermissionsThere are duplicate permissions in the specified parameter Permissions.指定的参数Permissions中存在重复的规则。
400InvalidParam.SecurityGroupRuleIdThe specified parameter SecurityGroupRuleId is not valid.指定的参数SecurityGroupRuleId不合法。
400InvalidParam.SecurityGroupRuleIdRepeatedThe specified parameter SecurityGroupRuleId is repeated.指定的参数SecurityGroupRuleId存在重复。
400InvalidGroupParameter.OperationDeniedThe attributes Policy, SourceGroupId, DestGroupId of enterprise level security groups are not allowed to be set or modified.企业级安全组不能指定Policy,SourceGroupId,DestGroupId等参数。
400InvalidSecurityGroupRule.RuleNotExistThe specified rule does not exist.指定的安全组规则不存在。
401InvalidOperation.SecurityGroupNotAuthorizedThe specified security group is not authorized to operate.没有权限操作当前安全组
403InvalidNicType.MismatchSpecified nic type conflicts with the authorization record.指定的 NIC 类型与规则信息冲突。
403InvalidGroupAuthItem.NotFoundSpecified group authorized item does not exist in our records.指定的组授权条目不存在。
403InvalidSecurityGroup.IsSameThe authorized SecurityGroupId should be different from the DestGroupId.已授权的 SecurityGroupId 不能与 DestGroupId 相同。
403InvalidParamter.ConflictThe specified SecurityGroupId should be different from the SourceGroupId.授权与被授权安全组必须不同。
403InvalidOperation.ResourceManagedByCloudProduct%s云产品托管的安全组不支持修改操作。
404InvalidSecurityGroupId.NotFoundThe specified SecurityGroupId does not exist.指定的安全组在该用户账号下不存在,请您检查安全组 ID 是否正确。
404InvalidDestGroupId.NotFoundThe DestGroupId provided does not exist in our records.指定的出方向安全组不存在。
404InvalidSecurityGroupRuleId.NotFoundThe specified SecurityGroupRuleId is not exists.指定的SecurityGroupRuleId不存在。
404InvalidPrefixListId.NotFoundThe specified prefix list was not found.前缀列表不存在。

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

变更历史

变更时间变更内容概要操作
2024-12-04OpenAPI 错误码发生变更查看变更详情
2024-06-20OpenAPI 错误码发生变更查看变更详情
2023-11-21OpenAPI 错误码发生变更查看变更详情
2023-04-07OpenAPI 错误码发生变更查看变更详情
2022-09-05OpenAPI 错误码发生变更查看变更详情
2022-07-13OpenAPI 描述信息更新、OpenAPI 错误码发生变更、OpenAPI 入参发生变更查看变更详情
2022-05-07OpenAPI 错误码发生变更查看变更详情
相关文章

AuthorizeSecurityGroup - 增加安全组入方向规则 2025-04-01 11:58

本接口是阿里云 ECS 中用于增加一条或多条安全组入方向规则的接口。通过该接口,用户可以指定安全组入方向的访问权限,允许或者拒绝其他设备发送入方向流量到安全组内的实例,从而实现对网络访问的精细控制。

AuthorizeSecurityGroupEgress - 增加安全组出方向规则 2025-04-01 11:58

本接口是阿里云 ECS 中用于增加一条或多条安全组出方向规则的接口。通过该接口,用户可以指定安全组出方向的访问权限,允许或拒绝安全组内的实例发送出方向流量到其他设备,从而实现对网络访问的精细控制。

CreateSecurityGroup - 创建安全组 2025-04-01 11:58

本接口用于创建一个安全组。 接口说明

DeleteSecurityGroup - 删除安全组 2025-04-01 11:58

本接口用于删除一个安全组,并关联删除组内所有安全组规则。 接口说明

DescribeSecurityGroupAttribute - 查询安全组和组内规则信息 2025-04-01 11:58

本接口主要用于查询一个指定安全组的详细信息,并关联查询安全组规则详细信息列表。

DescribeSecurityGroupReferences - 查询被授权的安全组列表 2025-04-01 11:58

本接口用于查询一个或多个指定安全组已经被授权的其他安全组列表信息。 接口说明

目录
Copyright © 2025 your company All Rights Reserved. Powered by 博智数字服务平台.
闽ICP备08105208号-1