Deletes an inbound rule from a security group and revoke inbound permissions of the security group.

Description

The source is where the packet is coming from and the destination is where the packet is going to.

You can determine an inbound rule by specifying one of the following groups of parameters. You cannot determine a security group rule by specifying only one parameter.

  • Parameters used to revoke access permissions from specified IP address segments: IpProtocol, PortRange, SourcePortRange (optional), NicType, Policy, DestCidrIp, and SourceCidrIp (optional).
  • Parameters used to revoke access permissions from other security groups: IpProtocol, PortRange, SourcePortRange (optional), NicType, Policy, DestCidrIp (optional), DestGroupOwnerAccount, and DestGroupId.

Debugging

You can use API Explorer to perform debugging. API Explorer allows you to perform various operations to simplify API usage. For example, you can retrieve APIs, call APIs, and dynamically generate SDK example code.

Request parameters

Name Type Required Example Description
IpProtocol String Yes icmp

The transport layer protocol. This parameter is case-sensitive. Valid values:

  • icmp
  • gre
  • tcp
  • udp
  • all: All protocols are supported.
PortRange String Yes 1/200

The range of destination ports relevant to the transport layer protocol. Valid values:

  • When IpProtocol is set to tcp or udp, the port number range is 1 to 65535. Separate the starting port and the ending port with a forward slash (/). Correct example: 1/200. Incorrect example: 200/1.
  • When IpProtocol is set to icmp, the port number range is -1/-1, indicating that all values are valid.
  • When IpProtocol is set to gre, the port number range is -1/-1, indicating that all values are valid.
  • When IpProtocol is set to all, the port number range is -1/-1, indicating that all values are valid.
RegionId String Yes cn-hangzhou

The ID of the region where the destination security group resides. You can call DescribeRegions to view the latest regions of Alibaba Cloud.

SecurityGroupId String Yes sg-securitygroupid1

The ID of the destination security group.

Action String No RevokeSecurityGroup

The operation that you want to perform. Set the value to RevokeSecurityGroup.

ClientToken String No 123e4567-e89b-12d3-a456-426655440000

A client token. It is used to ensure the idempotency of requests. The value of this parameter is generated by the client and is unique among different requests. The ClientToken parameter must be no more than 64 ASCII characters in length. For more information, see How to ensure idempotency.

Description String No FinanceJoshuaTest

The description of security group rules.

DestCidrIp String No 0.0.0.0/0

The range of destination IP addresses. CIDR blocks and IPv4 addresses are supported. Default value: 0.0.0.0/0.

Ipv6DestCidrIp String No 2001:db8:1234:1a00::XXX

The destination IPv6 CIDR block. CIDR blocks and IPv6 addresses are supported.

Note You can only specify IP addresses for VPC-connected instances.

Default value: null.

Ipv6SourceCidrIp String No 2001:db8:1234:1a00::XXX

The source IPv6 CIDR block. CIDR blocks and IPv6 addresses are supported.

Note You can only specify IP addresses for VPC-connected instances.

Default value: null.

NicType String No intranet

The NIC Type. Valid values:

  • internet
  • intranet

If SourceGroupId is specified and SourceCidrIp is not, the value of NicType can only be intranet. Default value: internet.

Policy String No accept

The access control policy. Valid values:

  • accept: grants access.
  • drop: denies access and returns no responses.

Default value: accept.

Priority String No 1

The priority of security group rules. Valid values: 1 to 100.

Default value: 1.

SourceCidrIp String No 0.0.0.0/0

The range of source IP addresses. CIDR blocks and IPv4 addresses are supported. Default value: 0.0.0.0/0.

SourceGroupId String No sg-securitygroupid2

The ID of the source security group to be revoked of access permissions.

Either SourceGroupId or SourceCidrIp must be specified.

If SourceGroupId is specified and SourceCidrIp is not, the value of NicType can only be intranet. If both the SourceGroupId and SourceCidrIp parameters are set, the SourceCidrIp parameter will take precedence.

SourceGroupOwnerAccount String No FinanceJoshua

The Alibaba Cloud account that manages the source security group.

  • If neither SourceGroupOwnerAccount nor SourceGroupOwnerId is specified, access permissions on other security groups are revoked.
  • If SourceCidrIp is specified, the SourceGroupOwnerAccount parameter will be ignored.
SourceGroupOwnerId Long No 155780923770

The Alibaba Cloud account that manages the source security group.

  • If neither SourceGroupOwnerId nor SourceGroupOwnerAccount is specified, access permissions on other security groups are revoked.
  • If SourceCidrIp is specified, the SourceGroupOwnerId parameter will be ignored.
SourcePortRange String No 1/200

The range of source ports relevant to the transport layer protocol. Valid values:

  • When IpProtocol is set to tcp or udp, the port number range is 1 to 65535. Separate the starting port and the ending port with a forward slash (/). Correct example: 1/200. Incorrect example: 200/1.
  • When IpProtocol is set to icmp, the port number range is -1/-1, indicating that all values are valid.
  • When IpProtocol is set to gre, the port number range is -1/-1, indicating that all values are valid.
  • When IpProtocol is set to all, the port number range is -1/-1, indicating that all values are valid.

Response parameters

Name Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=RevokeSecurityGroup
&SecurityGroupId=C0003E8B-B930-4F59-ADC0-0E209A9012B0
&SourceGroupId=sg-F876FF7BA
&SourceGroupOwnerAccount=test@aliyun.com
&IpProtocol=tcp
&PortRange=1/65535
&Priority=1
&<Common request parameters>

Successful response examples

XML format

<RevokeSecurityGroupResponse>
  <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
</RevokeSecurityGroupResponse>

JSON format

{
	"RequestId":"CEF72CEB-54B6-4AE8-B225-F876FF7BA984"
}

Error codes

HTTP status code Error code Error message Description
404 InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. The error message returned when the specified security group does not exist under this account. Check whether the security group ID is correct.
400 InvalidSecurityGroupId.Malformed The specified SecurityGroupId is not valid. The error message returned when the specified SecurityGroupId parameter is invalid.
400 InvalidIpProtocol.ValueNotSupported The specified IpProtocol does not exist. The error message returned when the specified value of the IpProtocol parameter is invalid.
403 InvalidNicType.Mismatch Specified nic type conflicts with the authorization record. The error message returned when the specified NIC type does not exist.
403 InvalidGroupAuthItem.NotFound Specified group authorized item does not exist in our records. The error message returned when the specified group authorization entry does not exist.
400 MissingParameter The input parameter "SourceGroupId" or "SourceCidrIp" cannot be both blank. The error message returned when the values of the SourceGroupId parameter and the SourceCidrIp parameter are blank.
400 InvalidPolicy.Malformed The specified parameter "Policy" is not valid. The error message returned when the specified parameter is invalid. You need check whether the parameter is correct.
400 MissingParameter.Source Either SourceCidrIp or SourceGroupId must be specified. The error message returned when the values of the SourceCidrIp parameter and the SourceGroupId parameter are blank.
400 InvalidParam.PortRange Please specify the PortRange or SourcePortRange in integer, less than 65535, and separate the range with ? /?. The error message returned when the range of destination or source port numbers is not specified. The port numbers must be smaller than 65,535. Use a forward slash (/) to separate the source and destination ports.
400 InvalidIpProtocol.ValueNotSupported The parameter IpProtocol must be specified with case insensitive TCP, UDP, ICMP, GRE or All. The error message returned when the protocol type is not TCP, UDP, ICMP, GRE or All.
400 InvalidPriority.Malformed The parameter Priority is invalid. The error message returned when the rule priority is invalid.
400 InvalidPriority.ValueNotSupported The parameter Priority is invalid. The error message returned when the rule priority is invalid.
400 InvalidParamter.Conflict The specified SecurityGroupId should be different from the SourceGroupId. The error message returned when a specified security group is the same as the source security group.
400 InvalidParam.SourceIp %s The error message returned when the source IP is invalid.
400 InvalidParam.DestIp %s The error message returned when the destination IP is invalid.
400 InvalidParam.Ipv6DestCidrIp %s The error message returned when the destination IP is not in IPv6.
400 InvalidParam.Ipv6SourceCidrIp %s The error message returned when the source IP is not in IPv6.
400 InvalidParam.Ipv4ProtocolConflictWithIpv6Address %s The error message returned when IPv4 addresses conflict with IPv6 addresses.
400 InvalidParam.Ipv6ProtocolConflictWithIpv4Address %s The error message returned when IPv4 addresses conflict with IPv6 addresses.
400 ILLEGAL_IPV6_CIDR %s The error message returned when the specified IPv6 address is invalid.

View error codes