全部产品
Search
文档中心

云服务器 ECS:DescribeSecurityGroupAttribute - 查询安全组和组内规则信息

更新时间:Jun 29, 2026

本接口主要用于查询一个指定安全组的详细信息,并关联查询安全组规则详细信息列表。

调试

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

调试

授权信息

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

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

ecs:DescribeSecurityGroupAttribute

get

*SecurityGroup

acs:ecs:{#regionId}:{#accountId}:securitygroup/{#securitygroupId}

  • ecs:tag

请求参数

名称

类型

必填

描述

示例值

SecurityGroupId

string

安全组 ID。

sg-bp1gxw6bznjjvhu3****

RegionId

string

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

cn-hangzhou

NicType

string

安全组规则的网卡类型。

  • 专有网络类型安全组的取值只能为:intranet(默认),即内网。

    说明

    如果传入 internet 或空值,则会默认转化为 intranet。

  • 经典网络类型安全组的取值范围:

    • internet(默认):公网。

    • intranet:内网。

    说明

    经典网络功能已下线,详情请参见下线公告

intranet

Direction

string

安全组规则授权方向。取值范围:

  • egress:安全组出方向。

  • ingress:安全组入方向。

  • all:不区分方向。

默认值:all。

all

NextToken

string

查询凭证(Token)。取值为上一次调用该接口返回的 NextToken 参数值,初次调用接口时无需设置该参数。

AAAAAdDWBF2****

MaxResults

integer

分页查询时每页的最大条目数。

  • 最小值:10。

  • 最大值:1000。

默认值为 500。

500

Attribute

string

安全组属性,取值范围:

  • snapshotPolicyIds:查询安全组关联的快照策略信息。

snapshotPolicyIds

返回参数

名称

类型

描述

示例值

object

VpcId

string

VPC ID。返回 VPC ID,表示该安全组网络类型为 VPC。否则,表示是经典网络类型安全组。

说明

经典网络功能已下线,详情请参见下线公告

vpc-bp1opxu1zkhn00gzv****

RequestId

string

请求 ID。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

InnerAccessPolicy

string

安全组内网络连通策略。可能值:

  • Accept:内网互通。

  • Drop:内网隔离。

Accept

Description

string

安全组描述信息。

This is description.

SecurityGroupId

string

安全组 ID。

sg-bp1gxw6bznjjvhu3****

SecurityGroupName

string

安全组名称。

SecurityGroupName Sample

RegionId

string

地域 ID。

cn-hangzhou

Permissions

object

Permission

array<object>

安全组权限规则集合。

object

SecurityGroupRuleId

string

安全组规则 ID。

sgr-bp12kewq32dfwrdi****

Direction

string

授权方向。

ingress

SourceGroupId

string

源端安全组,用于入方向授权。

sg-bp12kc4rqohaf2js****

DestGroupOwnerAccount

string

目的端安全组所属阿里云账户 ID。

1234567890

DestPrefixListId

string

目的端前缀列表 ID,用于出方向授权。

pl-x1j1k5ykzqlixabc****

DestPrefixListName

string

目的端前缀列表的名称。

DestPrefixListName Sample

SourceCidrIp

string

源端 IP 地址段,用于入方向授权。

0.0.0.0/0

Ipv6DestCidrIp

string

目的端 IPv6 地址段。

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

CreateTime

string

创建时间,UTC 时间。

2018-12-12T07:28:38Z

Ipv6SourceCidrIp

string

源端 IPv6 地址段。

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

DestGroupId

string

目的端安全组,用于出方向授权。

sg-bp1czdx84jd88i7v****

DestCidrIp

string

目的端 IP 地址段,用于出方向授权。

0.0.0.0/0

IpProtocol

string

IP 协议。

TCP

Priority

string

规则优先级。

1

DestGroupName

string

目的端安全组名称。

testDestGroupName

NicType

string

网络类型。

intranet

Policy

string

授权策略。

Accept

Description

string

安全组描述信息。

Description Sample 01

PortRange

string

端口范围。

80/80

SourcePrefixListName

string

源端前缀列表的名称。

SourcePrefixListName Sample

SourcePrefixListId

string

源端前缀列表 ID,用于入方向授权。

pl-x1j1k5ykzqlixdcy****

SourceGroupOwnerAccount

string

源端安全组所属阿里云账户 ID。

1234567890

SourceGroupName

string

源端安全组名称。

testSourceGroupName1

SourcePortRange

string

源端端口范围。

80/80

PortRangeListId

string

端口列表 ID。

prl-2ze9743****

PortRangeListName

string

端口列表的名称。

PortRangeListNameSample

NextToken

string

本次调用返回的查询凭证(Token)。当使用MaxResultsNextToken方式进行分页查询,且该返回值为空时,表示无更多返回的数据信息。

AAAAAdDWBF2****

SnapshotPolicyIds

object

SnapshotPolicyId

array

安全组关联的快照策略 ID 列表。

string

安全组关联的快照策略 ID。

sgsp-mj74****

示例

正常返回示例

JSON格式

{
  "VpcId": "vpc-bp1opxu1zkhn00gzv****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "InnerAccessPolicy": "Accept",
  "Description": "This is description.",
  "SecurityGroupId": "sg-bp1gxw6bznjjvhu3****",
  "SecurityGroupName": "SecurityGroupName Sample",
  "RegionId": "cn-hangzhou",
  "Permissions": {
    "Permission": [
      {
        "SecurityGroupRuleId": "sgr-bp12kewq32dfwrdi****",
        "Direction": "ingress",
        "SourceGroupId": "sg-bp12kc4rqohaf2js****",
        "DestGroupOwnerAccount": "1234567890",
        "DestPrefixListId": "pl-x1j1k5ykzqlixabc****",
        "DestPrefixListName": "DestPrefixListName Sample",
        "SourceCidrIp": "0.0.0.0/0",
        "Ipv6DestCidrIp": "2001:db8:1233:1a00::***",
        "CreateTime": "2018-12-12T07:28:38Z",
        "Ipv6SourceCidrIp": "2001:db8:1234:1a00::***",
        "DestGroupId": "sg-bp1czdx84jd88i7v****",
        "DestCidrIp": "0.0.0.0/0",
        "IpProtocol": "TCP",
        "Priority": "1",
        "DestGroupName": "testDestGroupName",
        "NicType": "intranet",
        "Policy": "Accept",
        "Description": "Description Sample 01",
        "PortRange": "80/80",
        "SourcePrefixListName": "SourcePrefixListName Sample",
        "SourcePrefixListId": "pl-x1j1k5ykzqlixdcy****",
        "SourceGroupOwnerAccount": "1234567890",
        "SourceGroupName": "testSourceGroupName1",
        "SourcePortRange": "80/80",
        "PortRangeListId": "prl-2ze9743****",
        "PortRangeListName": "PortRangeListNameSample"
      }
    ]
  },
  "NextToken": "AAAAAdDWBF2****",
  "SnapshotPolicyIds": {
    "SnapshotPolicyId": [
      "sgsp-mj74****"
    ]
  }
}

错误码

HTTP status code

错误码

错误信息

描述

400 InvalidNicType.ValueNotSupported The specified NicType does not exist. 指定的网络类型不存在,请您检查网络类型是否正确。
400 InvalidParamter Invalid Parameter. 输入的参数无效。
400 InvalidSecurityGroupId.Malformed The specified parameter "SecurityGroupId" is not valid. 指定的参数SecurityGroupId不合法。
400 MissingParameter.RegionId The parameter RegionId is missing.
400 InvalidParameter.AttributeNotSupported The specified value for parameter Attribute is not supported. Valid values: snapshotPolicyIds. 参数 Attribute 的指定值不被支持。有效值为:snapshotPolicyIds。
500 InternalError The request processing has failed due to some unknown error.
500 ServiceUnavailable The service is unavailable, please try again later. 服务暂时不可用,请稍候重试。
404 InvalidRegionId.NotFound The specified RegionId does not exist. 指定的地域 ID 不存在。
404 InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. 指定的安全组在该用户账号下不存在,请您检查安全组 ID 是否正确。

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

变更历史

更多信息,参考变更详情