全部產品
Search
文件中心

Elastic Compute Service:RevokeSecurityGroupEgress

更新時間:Oct 16, 2026

本介面用於刪除指定安全性群組內的一條或多條出方向安全性群組規則。

介面說明

重要 阿里雲已於 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:RevokeSecurityGroupEgress

delete

*SecurityGroup。

acs:ecs:{#regionId}:{#accountId}:securitygroup/{#securitygroupId}

  • ecs:tag
  • ecs:tag
  • ecs:tag
無

請求參數

名稱

類型

必填

描述

樣本值

RegionId

string

是

安全性群組所屬地域 ID。您可以呼叫 DescribeRegions 檢視最新的阿里雲地域清單。

cn-hangzhou

ClientToken

string

否

保證請求冪等性。從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元,且不能超過 64 個字元。更多詳情,請參閱如何保證冪等性。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

SecurityGroupId

string

是

安全性群組 ID。

sg-bp67acfmxazb4p****

SecurityGroupRuleId

array

否

安全性群組規則 ID 陣列。陣列長度:0~100。

string

否

安全性群組規則 ID。

說明

透過安全性群組規則 ID 刪除時,該參數為必填。

sgr-bp67acfmxa123b***

Permissions

array<object>

否

安全性群組規則陣列。陣列長度:0~100。

object

否

安全性群組規則。

Policy

string

否

存取權限。取值範圍:

  • accept:接受存取。

  • drop:拒絕存取,不返回拒絕資訊,表現為發起端請求逾時或者無法建立連線的類似資訊。

預設值:accept。

accept

Priority

string

否

安全性群組規則優先順序。數字越小,代表優先順序越高。取值範圍:1~100。

預設值:1。

1

IpProtocol

string

否

通訊協定類型。取值不區分大小寫。取值範圍:

  • TCP。

  • UDP。

  • ICMP。

  • ICMPv6。

  • GRE。

  • ALL:支援所有通訊協定。

TCP

DestCidrIp

string

否

需要撤銷存取權限的目的地 IPv4 CIDR 位址區塊。支援 CIDR 格式和 IPv4 格式的 IP 位址範圍。

10.0.0.0/8

Ipv6DestCidrIp

string

否

需要撤銷存取權限的目的地 IPv6 CIDR 位址區塊。支援 CIDR 格式和 IPv6 格式的 IP 位址範圍。

說明

僅在支援 IPv6 的 VPC 類型 ECS 執行個體上有效,且該參數與 DestCidrIp 參數不可同時設定。

2001:db8:1233:1a00::***

DestGroupId

string

否

需要撤銷存取權限的目的地安全性群組 ID。

  • 至少設定一項 DestGroupId 或者 DestCidrIp、Ipv6DestCidrIp 或 DestPrefixListId 參數中的一項。

  • 如果指定了 DestGroupId 沒有指定參數 DestCidrIp,則參數 NicType 取值只能為 intranet。

  • 如果同時指定了 DestGroupId 和 DestCidrIp,則預設以 DestCidrIp 為準。

您需要注意:

  • 企業安全性群組不支援授權安全性群組存取。

  • 普通安全性群組支援授權的安全性群組數量最多為 20 個。

sg-bp67acfmxa123b****

DestPrefixListId

string

否

需要撤銷存取權限的目的地前綴清單。您可以呼叫 DescribePrefixLists 查詢可以使用的前綴清單 ID。

注意事項:

當指定了 DestCidrIp、Ipv6DestCidrIp、DestGroupId 參數中的一個時,將忽略該參數。

更多資訊,請參閱安全性群組使用限制。

pl-x1j1k5ykzqlixdcy****

PortRange

string

否

安全性群組開放的各通訊協定相關的目的地連接埠範圍。取值範圍:

  • TCP/UDP 通訊協定:取值範圍為 1~65535。使用正斜線(/)隔開起始連接埠和終止連接埠。例如:1/200。

  • ICMP 通訊協定:-1/-1。

  • GRE 通訊協定:-1/-1。

  • ALL:-1/-1。

22/22

SourceCidrIp

string

否

來源 IPv4 CIDR 位址段。支援 CIDR 格式和 IPv4 格式的 IP 位址範圍。

用於支援五元組規則,請參閱安全性群組五元組規則。

10.0.0.0/8

Ipv6SourceCidrIp

string

否

來源 IPv6 CIDR 位址段。支援 CIDR 格式和 IPv6 格式的 IP 位址範圍。

用於支援五元組規則,請參閱安全性群組五元組規則。

說明

僅在支援 IPv6 的 VPC 類型 ECS 執行個體上有效,且該參數與 DestCidrIp 參數不可同時設定。

2001:db8:1234:1a00::***

SourcePortRange

string

否

安全性群組開放的各通訊協定相關的來源連接埠範圍。取值範圍:

  • TCP/UDP 通訊協定:取值範圍為 1~65535。使用正斜線(/)隔開起始連接埠和終止連接埠。例如:1/200。

  • ICMP 通訊協定:-1/-1。

  • GRE 通訊協定:-1/-1。

  • ALL:-1/-1。

用於支援五元組規則,請參閱安全性群組五元組規則。

22/22

DestGroupOwnerAccount

string

否

撤銷跨帳戶授權的安全性群組規則時,目的地安全性群組所屬的阿里雲帳戶。

  • 如果 DestGroupOwnerAccount 及 DestGroupOwnerId 均未設定,則認為是撤銷您其他安全性群組的存取權限。

  • 如果已經設定參數 DestCidrIp,則參數 DestGroupOwnerAccount 無效。

Test@aliyun.com

DestGroupOwnerId

string

否

撤銷跨帳戶授權的安全性群組規則時,目的地安全性群組所屬的阿里雲帳戶。

  • 如果 DestGroupOwnerId 及 DestGroupOwnerAccount 均未設定,則認為是撤銷您其他安全性群組的存取權限。

  • 如果您已經設定參數 DestCidrIp,則參數 DestGroupOwnerId 無效。

12345678910

NicType

string

否

安全性群組規則的網路介面卡類型,專屬網路 VPC 類型安全性群組規則無需設定網路介面卡類型,預設為 intranet,只能為 intranet。

說明

傳統網路功能已下線,詳情請參閱下線公告。傳統網路類型安全性群組規則的網路介面卡類型。取值範圍:

  • internet:公網網路介面卡。

  • intranet:內網網路介面卡。

intranet

Description

string

否

安全性群組規則的描述。長度為 1~512 個字元。

This is description.

PortRangeListId

string

否

連接埠清單 ID。 您可以呼叫 DescribePortRangeLists 查詢可以使用的連接埠清單 ID。

當您指定了 Permissions.N.PortRange 參數時,將忽略該參數。

更多資訊,請參閱安全性群組使用限制。

prl-2ze9743****

Policy deprecated

string

否

已廢棄。請使用 Permissions.N.Policy 來設定存取權限。

accept

Priority deprecated

string

否

已廢棄。請使用 Permissions.N.Priority 來指定規則優先順序。

1

IpProtocol deprecated

string

否

已廢棄。請使用 Permissions.N.IpProtocol 來指定通訊協定類型。

TCP

DestCidrIp deprecated

string

否

已廢棄。請使用 Permissions.N.DestCidrIp 來指定目的地 IPv4 CIDR 位址區塊。

10.0.0.0/8

Ipv6DestCidrIp deprecated

string

否

已廢棄。請使用 Permissions.N.Ipv6DestCidrIp 來指定目的地 IPv6 CIDR 位址區塊。

2001:db8:1233:1a00::***

DestGroupId deprecated

string

否

已廢棄。請使用 Permissions.N.DestGroupId 來指定目的地安全性群組 ID。

sg-bp67acfmxa123b****

DestPrefixListId deprecated

string

否

已廢棄。請使用 Permissions.N.DestPrefixListId 來指定來源前綴清單 ID。

pl-x1j1k5ykzqlixdcy****

PortRange deprecated

string

否

已廢棄。請使用 Permissions.N.PortRange 來指定連接埠範圍。

22/22

SourceCidrIp deprecated

string

否

已廢棄。請使用 Permissions.N.SourceCidrIp 來指定來源 IPv4 CIDR 位址段。

10.0.0.0/8

Ipv6SourceCidrIp deprecated

string

否

已廢棄。請使用 Permissions.N.Ipv6SourceCidrIp 來指定來源 IPv6 CIDR 位址段。

2001:db8:1234:1a00::***

SourcePortRange deprecated

string

否

已廢棄。請使用 Permissions.N.SourcePortRange 來指定來源連接埠範圍。

22/22

DestGroupOwnerAccount deprecated

string

否

已廢棄。請使用 Permissions.N.DestGroupOwnerAccount 來指定目的地安全性群組所屬的阿里雲帳戶。

Test@aliyun.com

DestGroupOwnerId deprecated

integer

否

已廢棄。請使用 Permissions.N.DestGroupOwnerId 來指定目的地安全性群組所屬的阿里雲帳戶 ID。

12345678910

NicType deprecated

string

否

已廢棄。請使用 Permissions.N.NicType 來指定網路介面卡類型。

intranet

Description deprecated

string

否

已廢棄。請使用 Permissions.N.Description 來指定規則的描述。

This is description.

返回參數

名稱

類型

描述

樣本值

object

RequestId

string

請求 ID。

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

樣本

正常返回樣本

JSON格式

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

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 InvalidIpProtocol.ValueNotSupported The parameter IpProtocol must be specified with case insensitive TCP, UDP, ICMP, GRE or All. IP 協定參數指定的值不支援。
400 InvalidIpPortRange.Malformed The specified parameter PortRange is not valid. IP 協定相關的連接埠號碼範圍格式不正確。
400 InvalidDestCidrIp.sMalformed The specified parameter DestCidrIp is not valid. 指定的參數 DestCidrIp 不合法。
400 MissingParameter The input parameter DestGroupId or DestCidrIp cannot be both blank.
400 InvalidPolicy.Malformed The specified parameter %s is not valid. 指定的參數無效,請您檢查該參數是否正確。
400 InvalidNicType.ValueNotSupported The specified parameter %s is not valid. 指定的網路類型不存在,請您檢查網路類型是否正確。
400 InvalidDestGroupId.Mismatch Specified security group and destination group are not in the same VPC. 指定的安全性群組和目標群組不在同一個 VPC 下。
400 InvalidDestCidrIp.Malformed The specified parameter DestCidrIp is not valid. 指定的 DestCidrIp 無效,請您檢查該參數是否正確。
400 MissingParameter.Dest One of the parameters DestCidrIp, Ipv6DestCidrIp, DestGroupId or DestPrefixListId in %s must be specified. 參數 DestCidrIp 和 DestGroupId 不能同時為空。
400 InvalidParam.PortRange The specified parameter %s is not valid. It should be two integers less than 65535 in ?/? format. 請指定目的連接埠範圍或來源連接埠範圍,連接埠號碼要小於 65535,如果是連接埠範圍需要使用斜線(/)分隔。
400 InvalidPriority.Malformed The parameter Priority is invalid. 指定的 Priority 參數不合法。
400 InvalidPriority.ValueNotSupported The specified parameter %s is invalid. 安全性群組規則的優先順序不合法,可選範圍為1-100。
400 InvalidParam.SourceIp The Parameters SourceCidrIp and Ipv6SourceCidrIp in %s cannot be set at the same time. 指定的參數 SourceIp 無效。
400 InvalidParam.DestIp The Parameters DestCidrIp and Ipv6DestCidrIp in %s cannot be set at the same time. 指定的參數 DestIp 無效。
400 InvalidParam.Ipv6DestCidrIp The specified parameter %s is not valid. 您輸入的參數無效。
400 InvalidParam.Ipv6SourceCidrIp The specified parameter %s is not valid. 您輸入的參數無效。
400 InvalidParam.Ipv4ProtocolConflictWithIpv6Address IPv6 address cannot be specified for IPv4-specific protocol. 您輸入的參數無效,請檢查 IPv4 協定下是否填寫了 IPv6 位址。
400 InvalidParam.Ipv6ProtocolConflictWithIpv4Address IPv4 address cannot be specified for IPv6-specific protocol. 您輸入的參數無效,請檢查 IPv6 協定下是否填寫了 IPv4 位址。
400 InvalidParameter.Ipv6CidrIp The specified Ipv6CidrIp is not valid. 指定的 Ipv6CidrIp 參數不合法。
400 InvalidGroupAuthParameter.OperationDenied The security group can not authorize to enterprise level security group. 安全性群組不能授權給企業級安全性群組。
400 InvalidSecurityGroupId.Malformed The specified parameter SecurityGroupId is not valid. 指定的 SecurityGroupId 不合法。
400 InvalidPortRange.Malformed The specified parameter PortRange must set. 必須設定參數「PortRange」。
400 InvalidSourcePortRange.Malformed The specified parameter SourcePortRange is not valid. 指定的參數 SourcePortRange 無效。
400 InvalidSecurityGroupDiscription.Malformed The specified security group rule description is not valid. 指定的安全性群組描述不合法。
400 NotSupported.ClassicNetworkPrefixList The prefix list is not supported when the network type of security group is classic. 安全性群組的網路類型為傳統網路,不支援首碼清單。
400 InvalidParam.SourceCidrIp The specified parameter %s is not valid. 參數SourceCidrIp不合法。
400 InvalidParam.DestCidrIp The specified parameter %s is not valid. 指定的參數「DestCidrIp」無效。
400 InvalidParam.Permissions The specified parameter Permissions cannot coexist with other parameters. 指定的參數Permissions不能與其他參數同時存在。
400 InvalidParam.DuplicatePermissions There are duplicate permissions in the specified parameter Permissions. 指定的參數Permissions中存在重複的規則。
400 InvalidParam.SecurityGroupRuleId The specified parameter SecurityGroupRuleId is not valid. 指定的參數SecurityGroupRuleId不合法。
400 InvalidParam.SecurityGroupRuleIdRepeated The specified parameter SecurityGroupRuleId is repeated. 指定的參數SecurityGroupRuleId存在重複。
400 InvalidGroupParameter.OperationDenied The attributes Policy, SourceGroupId, DestGroupId of enterprise level security groups are not allowed to be set or modified. 無法設定或修改企業級安全性群組的「Priority」、「Policy」、「SourceGroupId」、「DestGroupId」屬性。
400 InvalidSecurityGroupRule.RuleNotExist The specified rule does not exist. 指定的安全性群組規則不存在。
400 InvalidParam.ProtocolNotSupportPortRangeList The specified protocol does not support the port range list. 指定的通訊協定不支援連接埠清單。
400 InvalidPortRangeListId.NotFound The specified port range list was not found. 未找到指定的連接埠清單。
401 InvalidOperation.SecurityGroupNotAuthorized The specified security group is not authorized to operate. 沒有權限操作目前安全性群組。
403 InvalidNicType.Mismatch Specified nic type conflicts with the authorization record.
403 InvalidGroupAuthItem.NotFound Specified group authorized item does not exist in our records.
403 InvalidSecurityGroup.IsSame The authorized SecurityGroupId should be different from the DestGroupId. 已授權的 SecurityGroupId 不能與 DestGroupId 相同。
403 InvalidParamter.Conflict The specified SecurityGroupId should be different from the SourceGroupId. 授權與被授權安全性群組必須不同。
403 InvalidOperation.ResourceManagedByCloudProduct %s 雲端產品託管的安全性群組不支援修改操作。
404 InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. 指定的安全性群組在該使用者帳號下不存在,請您檢查安全性群組 id 是否正確。
404 InvalidDestGroupId.NotFound The DestGroupId provided does not exist in our records. 指定的出方向安全性群組不存在。
404 InvalidSecurityGroupRuleId.NotFound The specified SecurityGroupRuleId is not exists. 指定的SecurityGroupRuleId不存在。
404 InvalidPrefixListId.NotFound The specified prefix list was not found. 前綴清單不存在。

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情。