Queries the rules of a security group.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeSecurityGroupAttribute

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

SecurityGroupId String Yes sg-bp1gxw6bznjjvhu3****

The ID of the security group.

RegionId String Yes cn-hangzhou

The region ID of the security group. You can call the DescribeRegions operation to query the most recent list of regions.

NicType String No intranet

The network interface controller (NIC) type of the security group rule.

  • Valid values for rules of security groups in the classic network:
    • internet: this is the default value for security groups in the classic network.
    • intranet
      Note You can query security group rules of only one NIC type in a single call. To query security group rules of both NIC types, call the operation twice.
  • When the security group is in a virtual private cloud (VPC), set the value to intranet. This is also the default value for security groups in the VPC.
    Note If you set this parameter to internet or leave this parameter empty, the intranet value is automatically used.
Direction String No all

The direction in which the security group rule is applied. Valid values:

  • egress: outbound
  • ingress: inbound
  • all: outbound and inbound

Default value: all.

Response parameters

Parameter Type Example Description
VpcId String vpc-bp1opxu1zkhn00gzv****

The ID of the VPC. If a VPC ID is returned, the network type of the security group is VPC. If no VPC ID is returned, the network type of the security group is classic network.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

InnerAccessPolicy String Accept

The access control policy of the security group. Valid values:

  • Accept: All instances in the security group can communicate with each other.
  • Drop: All instances in the security group are isolated from each other.
Description String This is description.

The description of the security group.

SecurityGroupId String sg-bp1gxw6bznjjvhu3****

The ID of the destination security group.

SecurityGroupName String SecurityGroupName Sample

The name of the destination security group.

RegionId String cn-hangzhou

The region ID.

Permissions Array of Permission

Details about the security group rules.

Permission
SecurityGroupRuleId String sgr-bp12kewq32dfwrdi****

The ID of the security group rule.

Direction String ingress

The direction in which the security group rule is applied.

SourceGroupId String sg-bp12kc4rqohaf2js****

The source security group for inbound access control.

DestGroupOwnerAccount String 1234567890

The Alibaba Cloud account that manages the destination security group.

DestPrefixListId String pl-x1j1k5ykzqlixabc****

The ID of the destination prefix list for outbound access control.

DestPrefixListName String DestPrefixListName Sample

The name of the destination prefix list.

SourceCidrIp String 0.0.0.0/0

The source CIDR block for inbound access control.

Ipv6DestCidrIp String 2001:db8:1233:1a00::***

The destination IPv6 CIDR block.

CreateTime String 2018-12-12T07:28:38Z

The time when the security group rule was created. The time is displayed in UTC.

Ipv6SourceCidrIp String 2001:db8:1234:1a00::***

The source IPv6 CIDR block.

DestGroupId String sg-bp1czdx84jd88i7v****

The ID of the destination security group for outbound access control.

DestCidrIp String 0.0.0.0/0

The destination CIDR blocks for outbound access control.

IpProtocol String TCP

The transport layer protocol.

Priority String 1

The priority of the rule.

DestGroupName String testDestGroupName

The name of the destination security group.

NicType String intranet

The network type.

Policy String Accept

The access control policy.

Description String Description Sample 01

The description of the security group.

PortRange String 80/80

The port range.

SourcePrefixListName String SourcePrefixListName Sample

The name of the source prefix list.

SourcePrefixListId String pl-x1j1k5ykzqlixdcy****

The ID of the source prefix list for inbound access control.

SourceGroupOwnerAccount String 1234567890

The Alibaba Cloud account that manages the source security group.

SourceGroupName String testSourceGroupName1

The name of the source security group.

SourcePortRange String 80/80

The source port number range.

Examples

Sample requests

https://ecs.aliyuncs.com/?RegionId=cn-hangzhou
&SecurityGroupId=sg-bp1gxw6bznjjvhu3****
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeSecurityGroupAttributeResponse>
    <SecurityGroupId>sg-bp1gxw6bznjjvhu3****</SecurityGroupId>
    <InnerAccessPolicy>Accept</InnerAccessPolicy>
    <SecurityGroupName>SecurityGroupName Sample</SecurityGroupName>
    <Description>This is description.</Description>
    <RegionId>cn-hangzhou</RegionId>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
    <Permissions>
        <Permission>
            <SecurityGroupRuleId>sgr-bp12swerrtfcy****</SecurityGroupRuleId>
            <SourceCidrIp>0.0.0.0/0</SourceCidrIp>
            <Description>Description Sample 01</Description>
            <DestCidrIp/>
            <NicType>intranet</NicType>
            <DestGroupName/>
            <PortRange>22/22</PortRange>
            <DestGroupId/>
            <Ipv6DestCidrIp/>
            <DestPrefixListId/>
            <DestPrefixListName/>
            <Direction>ingress</Direction>
            <Priority>1</Priority>
            <IpProtocol>TCP</IpProtocol>
            <SourcePortRange/>
            <SourceGroupOwnerAccount/>
            <Policy>Accept</Policy>
            <CreateTime>2018-12-12T07:28:38Z</CreateTime>
            <SourceGroupId/>
            <DestGroupOwnerAccount/>
            <Ipv6SourceCidrIp/>
            <SourceGroupName/>
            <SourcePrefixListId/>
            <SourcePrefixListName/>
        </Permission>
    </Permissions>
    <VpcId>vpc-bp1opxu1zkhn00gzv****</VpcId>
</DescribeSecurityGroupAttributeResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "SecurityGroupId" : "sg-bp1gxw6bznjjvhu3****",
  "InnerAccessPolicy" : "Accept",
  "SecurityGroupName" : "SecurityGroupName Sample",
  "Description" : "This is description.",
  "RegionId" : "cn-hangzhou",
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "Permissions" : {
    "Permission" : [ {
      "SecurityGroupRuleId" : "sgr-bp12swerrtfcy****",
      "SourceCidrIp" : "0.0.0.0/0",
      "Description" : "Description Sample 01",
      "DestCidrIp" : "",
      "NicType" : "intranet",
      "DestGroupName" : "",
      "PortRange" : "22/22",
      "DestGroupId" : "",
      "Ipv6DestCidrIp" : "",
      "DestPrefixListId" : "",
      "DestPrefixListName" : "",
      "Direction" : "ingress",
      "Priority" : 1,
      "IpProtocol" : "TCP",
      "SourcePortRange" : "",
      "SourceGroupOwnerAccount" : "",
      "Policy" : "Accept",
      "CreateTime" : "2018-12-12T07:28:38Z",
      "SourceGroupId" : "",
      "DestGroupOwnerAccount" : "",
      "Ipv6SourceCidrIp" : "",
      "SourceGroupName" : "",
      "SourcePrefixListId" : "",
      "SourcePrefixListName" : ""
    } ]
  },
  "VpcId" : "vpc-bp1opxu1zkhn00gzv****"
}

Error codes

HttpCode Error code Error message Description
400 InvalidNicType.ValueNotSupported The specified NicType does not exist. The error message returned because the specified NicType parameter does not exist.
400 InvalidParamter Invalid Parameter The error message returned because a specified parameter is invalid.
404 InvalidRegionId.NotFound The specified RegionId does not exist. The error message returned because the specified RegionId parameter does not exist.
404 InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. The error message returned because the specified security group does not exist in this account. Check whether the security group ID is correct.
500 InternalError The request processing has failed due to some unknown error. The error message returned because an internal error has occurred. Try again later. If the error persists, submit a ticket.

For a list of error codes, see Service error codes.