阅读400 返回首页    go iPhone_iPad_Mac_手机_平板_苹果apple


授权安全组权限__安全组相关接口_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-阿里云