AuthorizeSecurityGroup
本介面是阿里雲 ECS 中用於增加一條或多條安全性群組入方向規則的介面。透過該介面,使用者可以指定安全性群組入方向的存取權限,允許或者拒絕其他裝置傳送入方向流量到安全性群組內的執行個體,從而實現對網路存取的精細控制。
介面說明
使用須知
數量限制: 單張彈性網卡關聯的所有安全性群組的規則(包括入方向規則與出方向規則)數量之和不能超過 1000。具體限制請參見安全性群組使用限制。
優先順序設定: 安全性群組入方向規則優先順序(Priority)可選範圍為 1~100。數字越小,代表優先順序越高,優先順序相同的安全性群組規則,優先以拒絕存取(drop)的規則為準。
注意事項
如果指定的安全性群組規則已存在,此次呼叫成功,但不會增加規則。
規則確定方式
確定一條安全性群組入方向規則必要的一組相關參數:
來源端設定:選擇 SourceCidrIp(IPv4 位址)、Ipv6SourceCidrIp(IPv6 位址)、SourcetPrefixListId(前綴列表 ID)、SourceGroupId(來源端安全性群組)中的一項。
目的端連接埠範圍:PortRange。
協定類型:IpProtocol。
權限策略:Policy。
企業安全性群組不支援授權其他安全性群組存取,普通安全性群組支援授權的安全性群組數量最多為 20 個。
請求示例
假設要在杭州地域下指定安全性群組中增加幾條不同來源端的入方向規則:
-
增加指定 IP 位址段的存取權限。
"RegionId":"cn-hangzhou", //設定地域 "SecurityGroupId":"sg-bp67acfmxazb4p****", //設定安全性群組 "Permissions":[ { "SourceCidrIp":"10.0.0.0/8", //設定來源端 IPv4 位址 "PortRange":"22/22", //設定連接埠範圍 "IpProtocol":"TCP", //設定協定類型 "Policy":"Accept" //設定存取策略 } ] -
增加一條其他安全性群組和一條前綴列表的存取權限。
"RegionId":"cn-hangzhou", "SecurityGroupId":"sg-bp67acfmxazb4p****", "Permissions":[ { "SourceGroupId":"sg-bp17vs63txqxbd****", //設定來源端安全性群組 "PortRange":"22/22", "IpProtocol":"TCP", "Policy":"Drop" },{ "SourcePrefixListId":"pl-x1j1k5ykzqlixdcy****", //設定來源端前綴列表 "PortRange":"22/22", "IpProtocol":"TCP", "Policy":"Drop" } ]
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
|
操作 |
存取層級 |
資源類型 |
條件關鍵字 |
關聯操作 |
|
ecs:AuthorizeSecurityGroup |
create |
*All Resource
|
|
無 |
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| RegionId |
string |
是 |
安全性群組所屬地域 ID。您可以呼叫 DescribeRegions 查看最新的阿里雲地域列表。 |
cn-hangzhou |
| RegionId |
string |
是 |
安全性群組所屬地域 ID。您可以呼叫 DescribeRegions 查看最新的阿里雲地域列表。 |
cn-hangzhou |
| RegionId |
string |
是 |
安全性群組所屬地域 ID。您可以呼叫 DescribeRegions 查看最新的阿里雲地域列表。 |
cn-hangzhou |
| ClientToken |
string |
否 |
保證請求冪等性。從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元,且不能超過 64 個字元。更多資訊,請參見如何保證冪等性。 |
123e4567-e89b-12d3-a456-426655440000 |
| ClientToken |
string |
否 |
保證請求冪等性。從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元,且不能超過 64 個字元。更多資訊,請參見如何保證冪等性。 |
123e4567-e89b-12d3-a456-426655440000 |
| SecurityGroupId |
string |
是 |
安全性群組 ID。 |
sg-bp67acfmxazb4p**** |
| SecurityGroupId |
string |
是 |
安全性群組 ID。 |
sg-bp67acfmxazb4p**** |
| Permissions |
array<object> |
否 |
安全性群組規則陣列。陣列長度:1~100。 |
|
|
object |
否 |
安全性群組規則。 |
||
| Policy |
string |
否 |
設定存取權限。取值範圍:
預設值:accept。 |
accept |
| Priority |
string |
否 |
安全性群組規則優先順序,數字越小,代表優先順序越高。取值範圍:1~100。 預設值:1。 |
1 |
| IpProtocol |
string |
否 |
網路層/傳輸層協定。支援兩類賦值:
|
ALL |
| SourceCidrIp |
string |
否 |
需要設定存取權限的來源端 IPv4 CIDR 位址段。支援 CIDR 格式和 IPv4 格式的 IP 位址範圍。 |
10.0.0.0/8 |
| Ipv6SourceCidrIp |
string |
否 |
需要設定存取權限的來源端 IPv6 CIDR 位址段。支援 CIDR 格式和 IPv6 格式的 IP 位址範圍。 說明
僅在支援 IPv6 的 VPC 類型 ECS 執行個體上有效,且該參數與 |
2001:250:6000::*** |
| SourceGroupId |
string |
否 |
需要設定存取權限的來源端安全性群組 ID。
|
sg-bp67acfmxazb4p**** |
| SourcePrefixListId |
string |
否 |
需要設定存取權限的來源端前綴列表 ID。您可以呼叫 DescribePrefixLists 查詢可以使用的前綴列表 ID。 注意事項: 當您指定了 更多資訊,請參見安全性群組使用限制。 |
pl-x1j1k5ykzqlixdcy**** |
| PortRange |
string |
否 |
安全性群組開放的各協定相關的目的端連接埠範圍。取值範圍:
瞭解連接埠的應用場景,請參見典型應用的常用連接埠。 |
80/80 |
| DestCidrIp |
string |
否 |
目的端 IPv4 CIDR 位址段。支援 CIDR 格式和 IPv4 格式的 IP 位址範圍。 用於支援五元組規則,請參見安全性群組五元組規則。 |
10.0.0.0/8 |
| Ipv6DestCidrIp |
string |
否 |
目的端 IPv6 CIDR 位址段。支援 CIDR 格式和 IPv6 格式的 IP 位址範圍。 用於支援五元組規則,請參見安全性群組五元組規則。 說明
僅在支援 IPv6 的 VPC 類型 ECS 執行個體上有效,且該參數與 |
2001:250:6000::*** |
| SourcePortRange |
string |
否 |
安全性群組開放的各協定相關的來源端連接埠範圍。取值範圍:
用於支援五元組規則,請參見安全性群組五元組規則。 |
7000/8000 |
| SourceGroupOwnerAccount |
string |
否 |
跨帳號設定安全性群組規則時,來源端安全性群組所屬的阿里雲帳號。
|
test@aliyun.com |
| SourceGroupOwnerId |
integer |
否 |
跨帳號設定安全性群組規則時,來源端安全性群組所屬的阿里雲帳號 ID。
|
1234567890 |
| NicType |
string |
否 |
經典網路類型安全性群組規則的網卡類型。取值範圍:
專有網路 VPC 類型安全性群組規則無需設定網卡類型,預設為 intranet,只能為 intranet。 設定安全性群組之間互相存取時,即僅指定了 DestGroupId 參數時,只能為 intranet。 預設值:internet。 |
intranet |
| Description |
string |
否 |
安全性群組規則的描述資訊。長度為 1~512 個字元。 |
This is description. |
| PortRangeListId |
string |
否 |
連接埠列表 ID。
您可以呼叫
|
prl-2ze9743**** |
Policy
deprecated
|
string |
否 |
已廢棄。請使用 |
accept |
Priority
deprecated
|
string |
否 |
已廢棄。請使用 |
1 |
IpProtocol
deprecated
|
string |
否 |
已廢棄。請使用 |
ALL |
SourceCidrIp
deprecated
|
string |
否 |
已廢棄。請使用 |
10.0.0.0/8 |
Ipv6SourceCidrIp
deprecated
|
string |
否 |
已廢棄。請使用 |
2001:250:6000::*** |
SourceGroupId
deprecated
|
string |
否 |
已廢棄。請使用 |
sg-bp67acfmxazb4p**** |
SourcePrefixListId
deprecated
|
string |
否 |
已廢棄。請使用 |
pl-x1j1k5ykzqlixdcy**** |
PortRange
deprecated
|
string |
否 |
已廢棄。請使用 |
22/22 |
DestCidrIp
deprecated
|
string |
否 |
已廢棄。請使用 |
10.0.0.0/8 |
Ipv6DestCidrIp
deprecated
|
string |
否 |
已廢棄。請使用 |
null |
SourcePortRange
deprecated
|
string |
否 |
已廢棄。請使用 |
22/22 |
SourceGroupOwnerAccount
deprecated
|
string |
否 |
已廢棄。請使用 |
test@aliyun.com |
SourceGroupOwnerId
deprecated
|
integer |
否 |
已廢棄。請使用 |
1234567890 |
NicType
deprecated
|
string |
否 |
已廢棄。請使用 |
intranet |
Description
deprecated
|
string |
否 |
已廢棄。請使用 |
This is description. |
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
|||
| RequestId |
string |
請求 ID。 |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
樣本
正常返回樣本
JSON格式
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | OperationDenied | The specified IpProtocol does not exist or IpProtocol and PortRange do not match. | |
| 400 | InvalidIpProtocol.Malformed | The specified parameter PortRange is not valid. | |
| 400 | InvalidSourceCidrIp.Malformed | The specified parameter SourceCidrIp is not valid. | |
| 400 | InvalidPolicy.Malformed | The specified parameter Policy is not valid. | |
| 400 | InvalidNicType.ValueNotSupported | The specified NicType does not exist. | |
| 400 | InvalidNicType.Mismatch | The specified NicType conflicts with the authorization record. | |
| 400 | InvalidSourceGroupId.Mismatch | Specified security group and source group are not in the same VPC. | |
| 400 | InvalidSourceGroup.NotFound | Specified source security group does not exist. | |
| 400 | InvalidPriority.Malformed | The parameter Priority is invalid. | |
| 400 | InvalidPriority.ValueNotSupported | The specified parameter %s is invalid. | |
| 400 | InvalidSecurityGroupDiscription.Malformed | The specified security group rule description parameter %s is not valid. | |
| 400 | InvalidSecurityGroup.InvalidNetworkType | The specified security group network type is not support this operation, please check the security group network types. For VPC security groups, ClassicLink must be enabled. | |
| 400 | MissingParameter.Source | One of the parameters SourceCidrIp, Ipv6SourceCidrIp, SourceGroupId or SourcePrefixListId in %s must be specified. | |
| 400 | InvalidParam.PortRange | The specified parameter %s is not valid. It should be two integers less than 65535 in ?/? format. | |
| 400 | InvalidIpProtocol.ValueNotSupported | The parameter %s must be specified with case insensitive TCP, UDP, ICMP, GRE or All. | |
| 400 | InvalidSecurityGroupId.Malformed | The specified parameter SecurityGroupId is not valid. | |
| 400 | InvalidParamter.Conflict | The specified SourceCidrIp should be different from the DestCidrIp. | |
| 400 | InvalidSourcePortRange.Malformed | The specified parameter SourcePortRange is not valid. | |
| 400 | InvalidPortRange.Malformed | The specified parameter PortRange must set. | |
| 400 | InvalidParam.SourceIp | The Parameters SourceCidrIp and Ipv6SourceCidrIp in %s cannot be set at the same time. | |
| 400 | InvalidParam.DestIp | The Parameters DestCidrIp and Ipv6DestCidrIp in %s cannot be set at the same time. | |
| 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. | |
| 400 | InvalidParam.Ipv6ProtocolConflictWithIpv4Address | IPv4 address cannot be specified for IPv6-specific protocol. | |
| 400 | InvalidParameter.Ipv6CidrIp | The specified Ipv6CidrIp is not valid. | |
| 400 | InvalidGroupAuthParameter.OperationDenied | The security group can not authorize to enterprise level security group. | |
| 400 | InvalidDestCidrIp.Malformed | The specified parameter DestCidrIp is not valid. | |
| 400 | InvalidParameter.Conflict | IPv6 and IPv4 addresses cannot exist at the same time. | |
| 400 | InvalidParam.PrefixListAddressFamilyMismatch | The address family of the specified prefix list does not match the specified CidrIp. | |
| 400 | NotSupported.ClassicNetworkPrefixList | The prefix list is not supported when the network type of security group is classic. | |
| 400 | AuthorizedGroupRule.LimitExceed | You have reached the limit on the number of group authorization rules that you can add to a security group.When authorization object of rule is security group, the limit is 20. | |
| 400 | InvalidParam.SourceCidrIp | The specified parameter %s is not valid. | |
| 400 | InvalidParam.DestCidrIp | The specified parameter %s is not valid. | |
| 400 | MissingParameter | %s | |
| 400 | InvalidParam.Permissions | The specified parameter Permissions cannot coexist with other parameters. | |
| 400 | InvalidParam.DuplicatePermissions | There are duplicate permissions in the specified parameter Permissions. | |
| 400 | InvalidGroupParameter.OperationDenied | The attributes Policy, SourceGroupId, DestGroupId of enterprise level security groups are not allowed to be set or modified. | |
| 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. | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 403 | InvalidSourceGroupId.Mismatch | NicType is required or NicType expects intranet. | |
| 403 | MissingParameter | The input parameter SourceGroupId or SourceCidrIp cannot be both blank. | |
| 403 | AuthorizationLimitExceed | The limit of authorization records in the security group reaches. | |
| 403 | InvalidParamter.Conflict | The specified SecurityGroupId should be different from the SourceGroupId. | |
| 403 | InvalidNetworkType.Mismatch | The specified SecurityGroup network type should be same with SourceGroup network type (vpc or classic). | |
| 403 | InvalidNetworkType.Conflict | The specified SecurityGroup network type should be same with SourceGroup network type (vpc or classic). | |
| 403 | InvalidOperation.ResourceManagedByCloudProduct | %s | |
| 403 | LimitExceed.PrefixListAssociationResource | The number of resources associated with the prefix list exceeds the limit. | |
| 404 | InvalidSecurityGroupId.NotFound | The specified SecurityGroupId does not exist. | |
| 404 | InvalidSourceGroupId.NotFound | The SourceGroupId provided does not exist in our records. | |
| 404 | InvalidPrefixListId.NotFound | The specified prefix list was not found. |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。