閱讀400 返回首頁    go 魔獸


授權安全組權限__安全組相關接口_API 參考_雲服務器 ECS-阿裏雲

描述

設定安全組In方向的訪問權限。

  • 可支持的授權策略為:accept(接受訪問),drop (拒絕訪問)。
  • 可支持不同的網絡類型,如NicType可選擇internetintranet,分別表示公網或內網。VPC類型的ECS實例,隻支持intranet類型。
  • 單個安全組的授權規則最多為100條。
  • 安全組的優先級根據創建的時間降序排序匹配。
  • 規則優先級可選範圍為1-100,默認值為1,即最高優先級。數字越大,代表優先級越低。
  • 相同優先級的授權規則,授權策略為drop的規則優先。
  • 組和組之間的授權隻能在內網,即NicType隻能選擇intranet
  • 安全組規則由兩組可選參數中的一組組成:SourceGroupOwnerAccountSourceGroupIdIpProtocolPortRangeNicTypePolicy或者SourceCidrIpIpProtocolPortRangeNicTypePolicy。如匹配的規則已存在將會報錯。

支持兩種授權方式: 1、授權同一region(經典網絡)/同一VPC(VPC)內其他安全組(允許跨用戶授權)對其的訪問權限;2、授權指定某IP地址範圍(CIDR格式)對其的訪問權限

請求參數

名稱 類型 是否必須 描述
Action String 係統規定參數,取值:AuthorizeSecurityGroup
SecurityGroupId String 目標安全組編碼
RegionId String 目標安全組所屬Region ID
IpProtocol String IP協議,取值:tcp | udp | icmp | gre | all;
all表示同時支持四種協議
PortRange String IP協議相關的端口號範圍
  • 協議為tcp、udp時默認端口號,取值範圍為1~65535;例如“1/200”意思是端口號範圍為1~200,若輸入值為:“200/1”接口調用將報錯。
  • 協議為icmp時端口號範圍值為-1/-1;
  • gre協議時端口號範圍值為-1/-1;
  • 協議為all時端口號範圍值為-1/-1
SourceGroupId String 源安全組ID,SourceGroupId或者SourceCidrIp參數必須設置一項,如果兩項都設置,則默認對SourceCidrIp授權。如果指定了該字段且沒有指定SourceCidrIp,則NicType隻能選擇intranet
SourceGroupOwnerAccount String 跨用戶安全組授權時,源安全組所屬用戶的阿裏雲賬號。該參數可選,如果該參數及SourceGroupOwnerID均未設置,則默認為同一賬戶安全組間授權。SourceCidrIp如果已經被設置,則該參數無效。
SourceGroupOwnerID String 跨用戶撤銷安全組規則時,源安全組所屬用戶阿裏雲賬號ID。該參數可選,如果該參數及SourceGroupOwnerAccount均未設置,則默認為同一賬戶安全組間撤銷。SourceCidrIp如果已經被設置,則該參數無效。
SourceCidrIp String 源IP地址範圍,必須采用CIDR格式來指定IP地址範圍,默認值為0.0.0.0/0(表示不受限製),其他支持的格式如10.159.6.18/12。僅支持IPV4。
Policy String 授權策略,參數值可為:accept(接受訪問),drop (拒絕訪問)
默認值為:accept
Priority String 授權策略優先級,參數值可為:1-100
默認值為:1
NicType String 網絡類型,取值:
  • internet
  • intranet;
默認值為internet
當對安全組進行相互授權時(即指定了SourceGroupId且沒有指定SourceCidrIp),必須指定NicType為intranet

返回參數

全是公共返回參數,詳見公共返回參數

錯誤碼

錯誤代碼 描述 Http 狀態碼 語義
InvalidRegionId.NotFound The RegionId provided does not exist in our records. 404 指定的RegionId不存在
MissingParameter The input parameter “RegionId” that is mandatory for processing this request is not supplied. 400 RegionId參數未指定
InvalidSecurityGroupId.NotFound The SecurityGroupId provided does not exist in our records. 404 指定的SecurityGroupId不存在
MissingParameter The input parameter “SecurityGroupId” that is mandatory for processing this request is not supplied. 400 SecurityGroupId參數未指定
OperationDenied The specified IpProtocol does not exist or IpProtocol and PortRange do not match. 400 IP協議不存在或者IP協議和端口不匹配
MissingParameter The input parameter “IpProtocol” that is mandatory for processing this request is not supplied. 400 IpProtocol參數未指定
InvalidIpProtocol.Malformed The specified parameter “PortRange” is not valid. 400 IpProtocol參數格式不正確
InvalidPriority.Malformed The specified parameter “Priority” is not valid. 400 Priority參數格式不正確
MissingParameter The input parameter “PortRange” that is mandatory for processing this request is not supplied. 400 PortRange參數未指定
InvalidSourceGroupId.Mismatch NicType is required or NicType expects intranet. 403 需要明確NicType參數或者NicType必須為intranet
InvalidSourceCidrIp.Malformed The specified parameter “SourceCidrIp” is not valid. 400 SourceCidrIp參數格式不正確
MissingParameter The input parameter “SourceGroupId” or “SourceCidrIp” cannot be both blank. 403 SourceGroupId或者SourceCidrIp參數未指定
InvalidPolicy.Malformed The specified parameter “Policy” is not valid. 400 Policy參數格式不正確
InvalidNicType.ValueNotSupported The specified NicType does not exist. 400 NicType指定的值不支持
AuthorizationLimitExceed The limit of Authorization in one security group reachs. 403 安全組授權規則數達到上限
InvalidParamter.Conflict The specified SecurityGroupId should be different from the SourceGroupId. 403 SecurityGroupId和SourceGroupId為同一個安全組
InvalidSourceGroupId.Mismatch SourceGroupOwnerUserAccount is required. 403 指定的其他用戶的SourceGroup但是沒有指定SourceGroupOwnerUserAccount
InvalidSourceGroupId.Mismatch Specified security group and source group are not in the same VPC. 403 指定的安全組和源安全組不屬於同一個vpc
InvalidSourceGroupOwnerUserAccount.Mismatch The specified SourceGroupId is not belong to the SourceGroupOwnerUserAccount 403 指定的SourceGroup不屬於SourceGroupOwnerUserAccount指定的用戶
InvalidSourceGroupId.NotFound The SourceGroupId provided does not exist in our records. 404 指定的SourceGroup未找到

示例

請求示例

  • 授權其他安全組的訪問權限

    1. https://ecs.aliyuncs.com/?Action=AuthorizeSecurityGroup
    2. &SecurityGroupId=sg-F876FF7BA
    3. &SourceGroupId=sg-1651FBB64
    4. &SourceGroupOwnerAccount=test@aliyun.com
    5. &IpProtocol=tcp
    6. &PortRange=1/65535
    7. &<公共請求參數>
  • 授權指定網段/IP地址的訪問權限

    1. https://ecs.aliyuncs.com/?Action=AuthorizeSecurityGroup
    2. &SecurityGroupId=sg-F876FF7BA
    3. &SourceCidrIp=0.0.0.0/0
    4. &IpProtocol=tcp
    5. &PortRange=1/65535
    6. &<公共請求參數>

返回示例

XML格式

  1. <AuthorizeSecurityGroupResponse>
  2. <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
  3. </AuthorizeSecurityGroupResponse>

JSON格式

  1. {
  2. "RequestId":"CEF72CEB-54B6-4AE8-B225-F876FF7BA984"
  3. }

最後更新:2016-11-23 17:16:02

  上一篇:go 釋放彈性公網 IP__網絡相關接口_API 參考_雲服務器 ECS-阿裏雲
  下一篇:go 撤銷安全組規則__安全組相關接口_API 參考_雲服務器 ECS-阿裏雲