文档

ModifySecurityGroupRule - 修改安全组入方向规则的描述信息

更新时间:

调用ModifySecurityGroupRule修改入方向安全组规则。

接口说明

安全组相关的 API 文档中,入方向流量的发起端为源端(Source),数据传输的接收端为目的端(Dest)。

在您指定安全组规则 ID 修改安全组规则时,您需要注意以下使用限制:

  • 安全组规则的授权对象分为 CIDR 地址块(或 IP 地址)、安全组、前缀列表三种类型。您不能通过该接口修改已有安全组规则的授权对象类型。如原来授权对象类型为 IP 地址,您可以更改为另一个 IP 地址或 CIDR 地址块,但不能修改为安全组或前缀列表。
  • 安全组规则授权对象的 IP 地址族不支持修改。如原安全组规则授权对象 CIDR 地址块为 IPv4,您不能将其修改为 IPv6 的 CIDR 地址块。又如规则的授权对象为一个 IPv4 地址族的前缀列表,您不能将其修改为一个 IPv6 地址族的前缀列表。
  • 修改后的安全组规则不能与已有其它规则相同。
  • 字段不支持从非空修改为空,如果需要修改建议先增加一条新规则,再删除当前规则。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。
  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:
    • 对于必选的资源类型,用背景高亮的方式表示。
    • 对于不支持资源级授权的操作,用全部资源表示。
  • 条件关键字:是指云产品自身定义的条件关键字。
  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作访问级别资源类型条件关键字关联操作
ecs:ModifySecurityGroupRuleWrite
  • SecurityGroup
    acs:ecs:{#regionId}:{#accountId}:securitygroup/{#securitygroupId}
  • ecs:tag
  • ecs:SecurityGroupIpProtocols
  • ecs:SecurityGroupSourceCidrIps

请求参数

名称类型必填描述示例值
RegionIdstring

目标安全组所属地域 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。

cn-hangzhou
ClientTokenstring

保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符,且不能超过 64 个字符。更多信息,请参见如何保证幂等性

123e4567-e89b-12d3-a456-426655440000
SecurityGroupIdstring

安全组 ID。

sg-bp67acfmxazb4p****
SecurityGroupRuleIdstring

安全组规则 ID。
根据安全组规则 ID 修改规则时,该参数必填。

sgr-bp67acfmxa123b***
Policystring

访问权限。取值范围:

  • accept:接受访问。
  • drop:拒绝访问,不返回拒绝信息。

默认值:accept

accept
Prioritystring

安全组规则优先级。取值范围:1~100

默认值:1

1
IpProtocolstring

传输层协议。不区分大小写。取值范围:

  • ICMP
  • GRE
  • TCP
  • UDP
  • ALL:支持所有协议
all
SourceCidrIpstring

设置访问权限的源端 IPv4 CIDR 地址块。支持 CIDR 格式和 IPv4 格式的 IP 地址范围。

默认值:无

10.0.0.0/8
Ipv6SourceCidrIpstring

设置访问权限的源端 IPv6 CIDR 地址块。支持 CIDR 格式和 IPv6 格式的 IP 地址范围。

说明 仅支持 VPC 类型的 IP 地址,且该参数与SourceCidrIp参数不可同时设置。

默认值:无

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

设置访问权限的源端安全组 ID。至少设置一项SourceGroupId或者SourceCidrIp参数。

  • 如果指定了SourceGroupId没有指定参数SourceCidrIp,则参数NicType取值只能为 intranet。
  • 如果同时指定了SourceGroupIdSourceCidrIp,则默认以SourceCidrIp为准。
sg-bp67acfmxa123b****
SourcePrefixListIdstring

设置访问权限的源端前缀列表 ID。您可以调用 DescribePrefixLists 查询可以使用的前缀列表 ID。

当您指定了SourceCidrIpIpv6SourceCidrIpSourceGroupId参数中的一个时,将忽略该参数。

pl-x1j1k5ykzqlixdcy****
PortRangestring

目的端安全组开放的传输层协议相关的端口范围。取值范围:

  • TCP/UDP 协议:取值范围为 1~65535。使用斜线(/)隔开起始端口和终止端口。例如:1/200
  • ICMP 协议:-1/-1
  • GRE 协议:-1/-1
  • ALL:-1/-1
80/80
DestCidrIpstring

目的端 IPv4 CIDR 地址块。支持 CIDR 格式和 IPv4 格式的 IP 地址范围。

默认值:无

10.0.0.0/8
Ipv6DestCidrIpstring

目的端 IPv6 CIDR 地址段。支持 CIDR 格式和 IPv6 格式的 IP 地址范围。

说明 仅支持 VPC 类型的 IP 地址,且该参数与DestCidrIp参数不可同时设置。

默认值:无

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

源端安全组开放的传输层协议相关的端口范围。取值范围:

  • TCP/UDP 协议:取值范围为 1~65535。使用斜线(/)隔开起始端口和终止端口。例如:1/200
  • ICMP 协议:-1/-1
  • GRE 协议:-1/-1
  • ALL:-1/-1
80/80
SourceGroupOwnerAccountstring

跨账户设置安全组规则时,源端安全组所属的阿里云账户。

  • 如果SourceGroupOwnerAccountSourceGroupOwnerID均未设置,则认为是设置您其他安全组的访问权限。
  • 如果已经设置参数SourceCidrIp,则参数SourceGroupOwnerAccount无效。
EcsforCloud@Alibaba.com
SourceGroupOwnerIdlong

跨账户设置安全组规则时,源端安全组所属的阿里云账户。

  • 如果SourceGroupOwnerIdSourceGroupOwnerAccount均未设置,则认为是设置您其他安全组的访问权限。
  • 如果您已经设置参数SourceCidrIp,则参数SourceGroupOwnerId无效。
12345678910
NicTypestring

根据安全组规则 ID 修改规则时,不支持修改该参数。
如果需要修改,建议先增加一条新规则,再删除当前规则。

intranet
Descriptionstring

安全组规则的描述信息。长度为 1~512 个字符。

This is a new security group rule.

返回参数

名称类型描述示例值
object
RequestIdstring

请求 ID。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

示例

正常返回示例

JSON格式

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

错误码

HTTP status code错误码错误信息描述
400OperationDeniedThe specified IpProtocol does not exist or IpProtocol and PortRange do not match.指定的 IP 协议不存在,或与端口范围不匹配。
400InvalidIpProtocol.MalformedThe specified parameter PortRange is not valid.IP 协议参数格式不正确,PortRange 参数不正确。
400InvalidSourceCidrIp.MalformedThe specified parameter SourceCidrIp is not valid.源 IP 地址范围参数格式不正确。
400InvalidPolicy.MalformedThe specified parameter Policy is not valid.指定的参数无效,请您检查该参数是否正确。
400InvalidNicType.ValueNotSupportedThe specified NicType does not exist.指定的网络类型不存在,请您检查网络类型是否正确。
400InvalidNicType.MismatchThe specified NicType conflicts with the authorization record.指定的网卡类型与已有规则不匹配。
400InvalidSourceGroupId.MismatchSpecified security group and source group are not in the same VPC.指定的安全组和源安全组不在一个 VPC 内。
400InvalidSourceGroup.NotFoundSpecified source security group does not exist.指定的安全组入方向规则不存在,或相关参数缺失。
400InvalidPriority.MalformedThe parameter Priority is invalid.指定的参数 Priority 无效。
400InvalidPriority.ValueNotSupportedThe parameter Priority is invalid.指定的参数 Priority 无效。
400InvalidSecurityGroupDiscription.MalformedThe specified security group rule description is not valid.指定的安全组规则描述不合法。
400MissingParameter.SourceOne of the parameters SourceCidrIp, SourceGroupId or SourcePrefixListId must be specified.-
400InvalidParam.PortRangeThe specified parameter %s is not valid. It should be two integers less than 65535 in ?/? format.端口范围不合法,应为斜线分隔两个整数的格式。
400InvalidIpProtocol.ValueNotSupportedThe parameter IpProtocol must be specified with case insensitive TCP, UDP, ICMP, GRE or All.协议类型只能是TCP、UDP、ICMP、GRE或者All。
400InvalidParam.SourceIpThe Parameters SourceCidrIp and Ipv6SourceCidrIp in %s cannot be set at the same time.参数SourceCidrIp和Ipv6SourceCidrIp不能被同时设置。
400InvalidParam.DestIpThe Parameters DestCidrIp and Ipv6DestCidrIp in %s cannot be set at the same time.参数DestCidrIp和Ipv6DestCidrIp不能被同时设置。
400InvalidParam.Ipv6DestCidrIpThe specified parameter %s is not valid.指定的参数Ipv6DestCidrIp不合法。
400InvalidParam.Ipv6SourceCidrIpThe specified parameter %s is not valid.指定的参数Ipv6SourceCidrIp不合法。
400InvalidParam.Ipv4ProtocolConflictWithIpv6AddressIPv6 address cannot be specified for IPv4-specific protocol.IPv4协议不能指定IPv6地址。
400InvalidParam.Ipv6ProtocolConflictWithIpv4AddressIPv4 address cannot be specified for IPv6-specific protocol.IPv6协议不能指定IPv4地址。
400InvalidParameter.Ipv6CidrIpThe specified Ipv6CidrIp is not valid.指定的Ipv6CidrIp参数不合法。
400InvalidParam.DestCidrIpThe specified parameter %s is not valid.指定的参数DestCidrIp不合法。
400InvalidSourcePortRange.MalformedThe specified parameter SourcePortRange is not valid.指定的参数 SourcePortRange 无效。
400InvalidSecurityGroupId.MalformedThe specified parameter SecurityGroupId is not valid.指定的参数 SecurityGroupId 无效。
400InvalidParam.SourceCidrIpThe specified param SourceCidrIp is not valid.参数SourceCidrIp不合法。
400InvalidParam.DestCidrIpThe specified param DestCidrIp is not valid.您指定的参数DestCidrIp不合法。
400InvalidParameter.ConflictIPv6 and IPv4 addresses cannot exist at the same time.IPv6地址和IPv4地址不能同时指定。
400InvalidParam.SecurityGroupRuleIdThe specified parameter SecurityGroupRuleId is not valid.指定的参数SecurityGroupRuleId不合法。
400InvalidOperation.ModifySgRuleEntityTypeThe source or destination type of the rules cannot be modified.规则的源或目的类型不能被修改。
400AuthorizationLimitExceedThe limit of authorization records in the security group reaches.安全组授权规则数达到上限,请您检查授权规则是否合理。
400InvalidParam.ProtocolAndPortRangeMismatchThe specified Protocol and PortRange do not match.指定和协议和端口范围不匹配。
400InvalidParam.ProtocolAndAddressFamilyMismatchThe specified Protocol and address family do not match.指定的协议和地址族不匹配。
400InvalidParam.PrefixListAddressFamilyMismatchThe address family of the prefix list does not match the rule.前缀列表的地址族与规则不匹配。
400InvalidParam.InvalidModifyRuleRequestThe request parameters are illegal.请求参数不合法。
400InvalidOperation.ModifyNicTypeNicType is not allowed to modify.不允许修改NicType。
400InvalidParamter.ConflictThe specified SourceCidrIp should be different from the DestCidrIp.参数 SourceCidrIp 和 DestCidrIp 不能相同。
400InvalidIpProtocol.ValueNotSupportedThe parameter %s must be specified with case insensitive TCP, UDP, ICMP, GRE or All.协议Protocol字段不合法,应指定大小写不敏感的TCP,UDP,ICMP,GRE或All。
403InvalidSourceGroupId.MismatchNicType is required or NicType expects intrnet.需要明确IP段类型参数或者网络类型必须为内网。
403MissingParameterThe input parameter SourceGroupId or SourceCidrIp cannot be both blank.参数 SourceGroupId 和 SourceCidrIp 不能同时为空。
403InvalidParamter.ConflictThe specified SecurityGroupId should be different from the SourceGroupId.授权与被授权安全组必须不同。
403InvalidNetworkType.MismatchThe specified SecurityGroup network type should be same with SourceGroup network type (vpc or classic).指定的 SecurityGroup 的网络类型必须与 SouceGroup 的网络类型一致。
403InvalidOperation.ResourceManagedByCloudProduct%s云产品托管的安全组不支持修改操作。
404InvalidSecurityGroupId.NotFoundThe specified SecurityGroupId does not exist.指定的安全组在该用户账号下不存在,请您检查安全组 ID 是否正确。
404InvalidSourceGroupId.NotFoundThe SourceGroupId provided does not exist in our records.指定的入方向安全组不存在。
404SecurityGroupRule.NotFoundThe target security group rule not exist.目标安全组规则不存在。
404InvalidPrefixListId.NotFoundThe specified prefix list was not found.前缀列表不存在。
404InvalidSecurityGroupRuleId.NotFoundThe specified SecurityGroupRuleId is not exists.指定的SecurityGroupRuleId不存在。
500InternalErrorThe request processing has failed due to some unknown error.内部错误,请重试。

访问错误中心查看更多错误码。

变更历史

变更时间变更内容概要操作
2023-08-23OpenAPI 错误码发生变更看变更集
变更项变更内容
错误码OpenAPI 错误码发生变更
    错误码 404 变更
    删除错误码:400
    删除错误码:403
    删除错误码:500
2023-04-07OpenAPI 错误码发生变更看变更集
变更项变更内容
错误码OpenAPI 错误码发生变更
    错误码 400 变更
    错误码 500 变更
    删除错误码:403
    删除错误码:404
2022-09-05OpenAPI 描述信息更新、OpenAPI 错误码发生变更看变更集
变更项变更内容
API 描述OpenAPI 描述信息更新
错误码OpenAPI 错误码发生变更
    错误码 400 变更
    错误码 403 变更
    删除错误码:404
    删除错误码:500
2022-05-07OpenAPI 错误码发生变更看变更集
变更项变更内容
错误码OpenAPI 错误码发生变更
    错误码 400 变更
    错误码 404 变更
    删除错误码:403
    删除错误码:500
  • 本页导读 (1)
文档反馈