Queries basic information of security groups.
Description
Before you call this operation, take note of the following items:
- Basic information of security groups includes their IDs and descriptions. In the response, security groups are displayed in descending order of their IDs.
- We recommend that you use the NextToken and MaxResults parameters for a paged query. During a paged query, when you call the DescribeSecurityGroups operation to retrieve the first page of results, set MaxResults to specify the maximum number of entries to return in the call. The return value of NextToken is a pagination token, which can be used in the next call to retrieve a new page of results. When you call the DescribeSecurityGroups operation to retrieve a new page of results, set NextToken to the NextToken value returned in the previous call and set MaxResults to specify the maximum number of entries to return in this call. If the return value of NextToken is empty, the current page of results is the last page and no more results are to be returned.
- When you use Alibaba Cloud CLI to call an API operation, you must specify request parameter values of different data types in required formats. For more information, see Parameter format overview.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | DescribeSecurityGroups |
The operation that you want to perform. Set the value to DescribeSecurityGroups. |
RegionId | String | Yes | cn-hangzhou |
The region ID of the security group. You can call the DescribeRegions operation to query the most recent region list. |
VpcId | String | No | vpc-bp67acfmxazb4p**** |
The ID of the virtual private cloud (VPC) to which the security group belongs. |
PageNumber | Integer | No | 1 |
The number of the page to return. Pages start from page 1. Default value: 1. Note This parameter will be removed in the future. We recommend that you use the NextToken
and MaxResults parameters for a paged query.
|
PageSize | Integer | No | 10 |
The number of entries to return on each page. Maximum value: 50. Default value: 10. Note This parameter will be removed in the future. We recommend that you use the NextToken
and MaxResults parameters for a paged query.
|
SecurityGroupIds | String | No | ["sg-bp67acfmxazb4p****", "sg-bp67acfmxazb4p****", "sg-bp67acfmxazb4p****",....] |
The IDs of security groups. The value is a JSON array that consists of up to 100 security group IDs. Separate multiple security group IDs with commas (,). |
ResourceGroupId | String | No | rg-bp67acfmxazb4p**** |
The ID of the resource group to which the security group belongs. When this parameter is specified to query resources, up to 1,000 resources that belong to the specified resource group can be displayed in the response. |
NetworkType | String | No | vpc |
The network type of the security group. Valid values:
|
SecurityGroupId | String | No | sg-bp67acfmxazb4p**** |
The ID of the security group. |
SecurityGroupName | String | No | SGTestName |
The name of the security group. |
SecurityGroupType | String | No | normal |
The type of the security group. Valid values:
|
DryRun | Boolean | No | false |
Specifies whether to check the validity of the request without actually making the request. Valid values:
Default value: false. |
NextToken | String | No | e71d8a535bd9cc11 |
The query token. Set the value to the NextToken value returned in the previous call to the DescribeSecurityGroups operation. Leave this parameter empty the first time you call this operation. |
MaxResults | Integer | No | 10 |
The maximum number of entries to return on each page. If you specify the MaxResults
parameter, both the Maximum value: 100. Default value: 10. |
Tag.N.key | String | No | testkey |
The key of tag N 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 future compatibility.
|
Tag.N.Key | String | No | TestKey |
The key of tag N of the security group. Valid values of N: 1 to 20. If a single tag is specified to query resources, up to 1,000 resources that have this tag added can be displayed in the response. If multiple tags are specified to query resources, up to 1,000 resources that have all these tags added can be displayed in the response. To query more than 1,000 resources that have specified tags added, call the ListTagResources operation. |
Tag.N.Value | String | No | TestValue |
The value of tag N of the security group. Valid values of N: 1 to 20. |
Tag.N.value | String | No | testvalue |
The value of tag N 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 future compatibility.
|
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
PageSize | Integer | 10 |
The number of entries returned per page. Note This parameter will be removed in the future. We recommend that you use the NextToken
and MaxResults parameters for a paged query.
|
PageNumber | Integer | 1 |
The page number of the returned page. Note This parameter will be removed in the future. We recommend that you use the NextToken
and MaxResults parameters for a paged query.
|
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E |
The ID of the request. |
TotalCount | Integer | 20 |
The total number of security groups. If the |
RegionId | String | cn-hangzhou |
The region ID of the security group. |
SecurityGroups | Array of SecurityGroup |
Details about the security groups. |
|
SecurityGroup | |||
CreationTime | String | 2021-08-31T03:12:29Z |
The time when the security group was created. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC. |
VpcId | String | vpc-bp67acfmxazb4p**** |
The ID of the VPC to which the security group belongs. |
ServiceManaged | Boolean | false |
Indicates whether the user is an Alibaba Cloud service or a distributor. |
Description | String | TestDescription |
The description of the security group. |
SecurityGroupId | String | sg-bp67acfmxazb4p**** |
The ID of the security group. |
ResourceGroupId | String | rg-bp67acfmxazb4p**** |
The ID of the resource group to which the security group belongs. |
SecurityGroupName | String | SGTestName |
The name of the security group. |
EcsCount | Integer | 0 |
Note This parameter is in invitational preview and unavailable.
|
ServiceID | Long | 12345678910 |
The ID of the distributor to which the security group belongs. |
SecurityGroupType | String | normal |
The type of the security group. Valid values:
|
AvailableInstanceAmount | Integer | 0 |
Note This parameter is in invitational preview and unavailable.
|
Tags | Array of Tag |
The tags of the security group. |
|
Tag | |||
TagValue | String | TestValue |
The tag value of the security group. |
TagKey | String | TestKey |
The tag key of the security group. |
NextToken | String | e71d8a535bd9cc11 |
The query token returned in this call. If the return value of this parameter is empty when MaxResults and NextToken are used for a paged query, no more results are to be returned. |
Examples
Sample requests
https://ecs.aliyuncs.com/?Action=DescribeSecurityGroups
&RegionId=cn-hangzhou
&MaxResults=1
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<DescribeSecurityGroupsResponse>
<SecurityGroups>
<SecurityGroup>
<Description>TestDescription</Description>
<VpcId>vpc-bp67acfmxazb4p****</VpcId>
<ServiceManaged>false</ServiceManaged>
<SecurityGroupName>SGTestName</SecurityGroupName>
<ResourceGroupId>rg-bp67acfmxazb4p****</ResourceGroupId>
<SecurityGroupId>sg-bp67acfmxazb4p****</SecurityGroupId>
<CreationTime>2021-08-31T03:12:29Z</CreationTime>
<SecurityGroupType>normal</SecurityGroupType>
<Tags>
<Tag>
<TagKey>TestValue</TagKey>
<TagValue>TestValue</TagValue>
</Tag>
</Tags>
</SecurityGroup>
</SecurityGroups>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
<NextToken>e71d8a535bd9cc11</NextToken>
<RegionId>cn-hangzhou</RegionId>
</DescribeSecurityGroupsResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"SecurityGroups" : {
"SecurityGroup" : [ {
"Description" : "TestDescription",
"VpcId" : "vpc-bp67acfmxazb4p****",
"ServiceManaged" : false,
"SecurityGroupName" : "SGTestName",
"ResourceGroupId" : "rg-bp67acfmxazb4p****",
"SecurityGroupId" : "sg-bp67acfmxazb4p****",
"CreationTime" : "2021-08-31T03:12:29Z",
"SecurityGroupType" : "normal",
"Tags" : {
"Tag" : [ {
"TagKey" : "TestValue",
"TagValue" : "TestValue"
} ]
}
} ]
},
"RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
"NextToken" : "e71d8a535bd9cc11",
"RegionId" : "cn-hangzhou"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | NotSupported.PageNumberAndPageSize | The parameters PageNumber and PageSize are currently not supported, please use NextToken and MaxResults instead. | The error message returned because the PageNumber and PageSize parameters are not available. Use the NextToken and MaxResults parameters instead. |
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, visit the API Error Center.