You can call this operation to query basic information of security groups.

Description

Basic information of security groups includes security group IDs and descriptions. Security groups are displayed in descending order of their IDs.

When calling an API operation through Alibaba Cloud CLI, specify request parameter values of different data types in required formats. For more information, see CLI parameter formats.

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
RegionId String Yes cn-hangzhou

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

Action String No DescribeSecurityGroups

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

DryRun Boolean No false

Specifies whether to check the request only. Valid values:

  • true: The request is checked but basic information of the security group is not queried. Check items include whether your AccessKey pair is valid, whether RAM users are authorized, and whether the required parameters are specified. If the check fails, the corresponding error message is returned. If the check succeeds, the DryRunOperation error code is returned.
  • false: The request is checked, and a 2XX HTTP status code is returned and basic information of the security group is queried if the check succeeds.

Default value: false

NetworkType String No vpc

The network type of the security group. Valid values:

  • vpc
  • classic
PageNumber Integer No 1

The number of the page to return.

Pages start from page 1.

Default value: 1

PageSize Integer No 10

The number of entries to return on each page.

Valid values: 1 to 50

Default value: 10

ResourceGroupId String No rg-bp67acfmxazb4ph***

The ID of the resource group to which the security group belongs.

SecurityGroupId String No sg-bp67acfmxazb4ph***

The ID of the security group.

SecurityGroupIds String No ["sg-bp67acfmxazb4ph***", "sg-bp67acfmxazb4pi***", "sg-bp67acfmxazb4pj***",....]

The list of security group IDs. This list is in JSON array format. A maximum of 100 security group IDs can be entered at a time. Separate multiple security group IDs with commas (,).

SecurityGroupName String No DocTest

The name of the security group.

Tag.N.Key String No FinanceDept

The key of the Nth tag of the security group. Valid values of N: 1 to 20.

Tag.N.Value String No FinanceJoshua

The value of the Nth tag of the security group. Valid values of N: 1 to 20.

Tag.N.key String No null

The key of the Nth tag of the security group.

Note This parameter will be removed in the future. We recommend that you use the Tag.N.Key parameter to ensure compatibility.
Tag.N.value String No null

The value of the Nth tag of the security group.

Note This parameter will be removed in the future. We recommend that you use the Tag.N.Value parameter to ensure compatibility.
VpcId String No vpc-bp67acfmxazb4ph***

The ID of the VPC to which the security group belongs.

Response parameters

Parameter Type Example Description
PageNumber Integer 1

The page number of the returned page.

PageSize Integer 1

The number of entries returned per page.

RegionId String cn-hangzhou

The region ID of the security group.

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

The ID of the request.

SecurityGroups Array

An array of information about the security groups.

SecurityGroup

The information of the security group.

CreationTime String 2017-12-05T22:40:00Z

The time when the security group was created. The time follows the ISO8601 standard in the yyyy-MM-ddThh:mmZ format. The time is displayed in UTC.

Description String FinanceDept

The description of the security group.

ResourceGroupId String rg-bp67acfmxazb4ph***

The ID of the resource group to which the security group belongs.

SecurityGroupId String sg-bp67acfmxazb4ph***

The ID of the security group.

SecurityGroupName String DocTest

The name of the security group.

SecurityGroupType String normal

The type of the security group. Valid values:

  • normal: basic security group
  • enterprise: advanced security group
Tags Array

An array of tags of the security groups.

Tag

The tag of the security group.

TagKey String FinanceDept

The tag key of the security group.

TagValue String FinanceJoshua

The tag value of the security group.

VpcId String vpc-bp67acfmxazb4ph***

The ID of the VPC to which the security group belongs.

TotalCount Integer 49

The total number of security groups.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=DescribeSecurityGroups
&RegionId=cn-hangzhou
&PageSize=1
&PageNumber=1
&<Common request parameters>

Sample success responses

XML format

<DescribeSecurityGroupsResponse>
      <PageNumber>1</PageNumber>
      <TotalCount>49</TotalCount>
      <PageSize>1</PageSize>
      <RegionId>cn-hangzhou</RegionId>
      <RequestId>A1707FC0-430C-423A-B624-284046B20399</RequestId>
      <SecurityGroups>
            <SecurityGroup>
                  <CreationTime>2019-11-01T06:08:46Z</CreationTime>
                  <SecurityGroupId>sg-bp67acfmxazb4ph***</SecurityGroupId>
                  <Description></Description>
                  <SecurityGroupName>DocTest</SecurityGroupName>
                  <ResourceGroupId></ResourceGroupId>
                  <SecurityGroupType>normal</SecurityGroupType>
                  <VpcId>vpc-bp67acfmxazb4ph***</VpcId>
            </SecurityGroup>
      </SecurityGroups>
</DescribeSecurityGroupsResponse>

JSON format

{
	"PageNumber":1,
	"TotalCount":49,
	"PageSize":1,
	"RequestId":"A1707FC0-430C-423A-B624-284046B20399",
	"RegionId":"cn-hangzhou",
	"SecurityGroups":{
		"SecurityGroup":[
			{
				"CreationTime":"2019-11-01T06:08:46Z",
				"SecurityGroupId":"sg-bp67acfmxazb4ph***",
				"Tags":{
					"Tag":[]
				},
				"SecurityGroupName":"DocTest",
				"Description":"",
				"ResourceGroupId":"",
				"SecurityGroupType":"normal",
				"VpcId":"vpc-bp67acfmxazb4ph***"
			}
		]
	}
}

Error codes

HTTP status code Error code Error message Description
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 problem persists, submit a ticket.

For a list of error codes, visit the API Error Center.