撤销安全组授权规则
描述
撤销安全组的访问权限支持两种方式:一是撤销本Region内(经典网络)/本VPC内(VPC)其他安全组采用指定协议通过指定端口对本安全组的授权规则;二是撤销IP网段采用指定协议通过指定端口访问本安全组,只有调用授权接口授权的权限条目才可以删除。
安全组规则由两组可选参数中的一组组成:SourceGroupOwnerAccount、SourceGroupId、IpProtocol、PortRange、NicType、Policy或者SourceCidrIp、IpProtocol、PortRange、NicType、Policy。如匹配的规则找不到将会报错。
RevokeSecurityGroup和RevokeSecurityGroupEgress的区别
这两个方法都是用来操作安全组规则的,但是有区别:
RevokeSecurityGroup 是用来撤销“入方向”的安全组规则,也就是“In”方向上的规则;
RevokeSecurityGroupEgress 是用来撤销“出方向”的安全组规则。
一般来说,前者的使用更多,您根据实际情况来选择一个方法即可。
类似的,AuthorizeSecurityGroup和AuthorizeSecurityGroupEgress也是这样,前者授权入方向的规则,后者授权出方向的规则。
请求参数
名称 类型 是否必须 描述 Action String 是 系统规定参数,取值:RevokeSecurityGroup SecurityGroupId String 是 目标安全组ID 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
默认值为:accept Priority String 否 授权策略优先级,参数值可为:1-100
默认值为:1 NicType String 否 网络类型,取值:
- internet
- intranet;
当对安全组进行相互授权时(即指定了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参数未指定 InvalidIpProtocol.ValueNotSupported The specified IpProtocol does not exist. 400 IpProtocol参数指定的值不支持 MissingParameter The input parameter "IpProtocol" that is mandatory for processing this request is not supplied. 400 IpProtocol参数未指定 InvalidPriority.Malformed The specified parameter "Priority" is not valid. 400 Priority参数格式不正确 InvalidIpPortRange.Malformed The specified parameter "PortRange" is not valid. 400 PortRange格式不正确 MissingParameter The input parameter "PortRange" that is mandatory for processing this request is not supplied. 400 PortRange参数未指定 InvalidSourceGroupId.NotFound The SourceGroupId provided does not exist in our records. 404 指定的SourceGroupId不存在 InvalidSourceGroupId.Mismatch NicType is required or NicType expects intrnet. 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. 400 SourceGroupId或者SourceCidrIp参数未指定 InvalidPolicy.Malformed The specified parameter "Policy" is not valid. 400 Policy参数格式不正确 InvalidNicType.ValueNotSupported The specified NicType does not exist. 400 NicType指定的值不支持 InvalidSourceGroupId.Mismatch SourceGroupOwnerAccount is required 403 指定的其他用户的SourceGroup但是没有指定SourceGroupOwnerUserAccount InvalidSourceGroupOwnerUserAccount.Mismatch The specified SourceGroupId is not belong to the SourceGroupOwnerAccount 403 指定的SourceGroup不属于SourceGroupOwnerUserAccount指定的用户示例
请求示例
https://ecs.aliyuncs.com/?Action=RevokeSecurityGroup
&SecurityGroupId=C0003E8B-B930-4F59-ADC0-0E209A9012B0
&SourceGroupId=sg-F876FF7BA
&SourceGroupOwnerAccount=test@aliyun.com
&IpProtocol=tcp
&PortRange=1/65535
&<公共请求参数>
返回示例
JSON格式
{
"RequestId":"CEF72CEB-54B6-4AE8-B225-F876FF7BA984"
}
- 看不过瘾?点击下面链接!
- 阿里云如何使用新建专有网络接口
- 阿里云如何使用删除专有网络接口
- 阿里云如何使用查询专有网络列表接口
- 阿里云如何使用修改专有网络属性接口
- 阿里云如何使用查询路由器列表接口
- 阿里云如何使用修改路由器属性接口