调用DescribeSecurityGroupAttribute查询一个安全组的安全组规则。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 |
类型 |
是否必选 |
示例值 |
描述 |
Action | String | 是 | DescribeSecurityGroupAttribute | 系统规定参数。取值:DescribeSecurityGroupAttribute。 |
SecurityGroupId | String | 是 | sg-bp1gxw6bznjjvhu3**** | 安全组ID。 |
RegionId | String | 是 | cn-hangzhou | 安全组所属地域ID。您可以调用DescribeRegions查看最新的阿里云地域列表。 |
NicType | String | 否 | intranet | 安全组规则的网卡类型。
|
Direction | String | 否 | all | 安全组规则授权方向。取值范围:
默认值:all。 |
返回数据
名称 |
类型 |
示例值 |
描述 |
VpcId | String | vpc-bp1opxu1zkhn00gzv**** | VPC ID。如果返回VPC ID,表示该安全组网络类型为VPC。否则,表示是经典网络类型安全组。 |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E | 请求ID。 |
InnerAccessPolicy | String | Accept | 安全组内网络连通策略。可能值:
|
Description | String | This is description. | 安全组描述信息。 |
SecurityGroupId | String | sg-bp1gxw6bznjjvhu3**** | 目标安全组ID。 |
SecurityGroupName | String | SecurityGroupName Sample | 目标安全组名称。 |
RegionId | String | cn-hangzhou | 地域ID。 |
Permissions | Array of Permission | 安全组权限规则集合。 |
|
Permission | |||
SecurityGroupRuleId | String | sgr-bp12kewq32dfwrdi**** | 安全组规则ID。 |
Direction | String | ingress | 授权方向。 |
SourceGroupId | String | sg-bp12kc4rqohaf2js**** | 源端安全组,用于入方向授权。 |
DestGroupOwnerAccount | String | 1234567890 | 目的端安全组所属阿里云账户ID。 |
DestPrefixListId | String | pl-x1j1k5ykzqlixabc**** | 目的端前缀列表ID,用于出方向授权。 |
DestPrefixListName | String | DestPrefixListName Sample | 目的端前缀列表的名称。 |
SourceCidrIp | String | 0.0.0.0/0 | 源端IP地址段,用于入方向授权。 |
Ipv6DestCidrIp | String | 2001:db8:1233:1a00::*** | 目的端IPv6地址段。 |
CreateTime | String | 2018-12-12T07:28:38Z | 创建时间,UTC时间。 |
Ipv6SourceCidrIp | String | 2001:db8:1234:1a00::*** | 源端IPv6地址段。 |
DestGroupId | String | sg-bp1czdx84jd88i7v**** | 目的端安全组,用于出方向授权。 |
DestCidrIp | String | 0.0.0.0/0 | 目的端IP地址段,用于出方向授权。 |
IpProtocol | String | TCP | IP协议。 |
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 | pl-x1j1k5ykzqlixdcy**** | 源端前缀列表ID,用于入方向授权。 |
SourceGroupOwnerAccount | String | 1234567890 | 源端安全组所属阿里云账户ID。 |
SourceGroupName | String | testSourceGroupName1 | 源端安全组名称。 |
SourcePortRange | String | 80/80 | 源端端口范围。 |
示例
请求示例
https://ecs.aliyuncs.com/?RegionId=cn-hangzhou
&SecurityGroupId=sg-bp1gxw6bznjjvhu3****
&<公共请求参数>
正常返回示例
XML
格式
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
格式
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****"
}
错误码
HttpCode |
错误码 |
错误信息 |
描述 |
400 | InvalidNicType.ValueNotSupported | The specified NicType does not exist. | 指定的网络类型不存在,请您检查网络类型是否正确。 |
400 | InvalidParamter | Invalid Parameter. | 输入的参数无效。 |
404 | InvalidRegionId.NotFound | The specified RegionId does not exist. | 指定的地域 ID 不存在。 |
404 | InvalidSecurityGroupId.NotFound | The specified SecurityGroupId does not exist. | 指定的安全组在该用户账号下不存在,请您检查安全组 ID 是否正确。 |
500 | InternalError | The request processing has failed due to some unknown error. | 内部错误,请重试。 |
访问错误中心查看更多错误码。