创建安全组规则 - CreateSecurityGroupRule
功能介绍
创建安全组规则。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
- 如果使用身份策略授权,需具备如下身份策略权限。
授权项
访问级别
资源类型(*为必须)
条件键
别名
依赖的授权项
vpc:securityGroupRules:create
Write
securityGroupRule *
- vpc:SecurityGroupRuleDirection
- vpc:SecurityGroupRuleProtocol
- vpc:SecurityGroupRuleAction
- vpc:SecurityGroupRulePort
- vpc:SecurityGroupRuleRemoteIpAddressGroup
- vpc:SecurityGroupRuleRemoteSecurityGroup
- vpc:SecurityGroupRuleRemoteIpPrefix
-
-
securityGroup *
- g:EnterpriseProjectId
- vpc:SecurityGroupId
- g:ResourceTag/<tag-key>
URI
POST /v1/{project_id}/security-group-rules
请求参数
名称 | 是否必选 | 参数类型 | 说明 |
|---|---|---|---|
security_group_rule | 是 | security_group_rule object | 安全组规则对象,请参见表2。 |
名称 | 是否必选 | 参数类型 | 说明 |
|---|---|---|---|
security_group_id | 是 | String | 所属安全组ID |
description | 否 | String |
|
direction | 是 | String |
|
ethertype | 否 | String |
|
protocol | 否 | String |
|
port_range_min | 否 | Integer |
|
port_range_max | 否 | Integer |
|
remote_ip_prefix | 否 | String |
|
remote_group_id | 否 | String |
|
remote_address_group_id | 否 | String |
|
请求示例
- 创建一条入方向安全组规则,所在安全组id为a7734e61-b545-452d-a3cd-0189cbd9747a。
POST https://{Endpoint}/v1/{project_id}/security-group-rules { "security_group_rule": { "direction": "ingress", "port_range_min": "80", "ethertype": "IPv4", "port_range_max": "80", "protocol": "tcp", "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", "security_group_id": "a7734e61-b545-452d-a3cd-0189cbd9747a" } }POST https://{Endpoint}/v1/{project_id}/security-group-rules { "security_group_rule": { "direction": "ingress", "port_range_min": "80", "ethertype": "IPv6", "port_range_max": "90", "protocol": "tcp", "security_group_id": "a7734e61-b545-452d-a3cd-0189cbd9747a" } }
响应参数
名称 | 参数类型 | 说明 |
|---|---|---|
security_group_rule | security_group_rule object | 安全组规则对象,请参见表4 |
名称 | 参数类型 | 说明 |
|---|---|---|
id | String | 安全组规则标识。 |
description | String |
|
security_group_id | String | 安全组标识。 |
direction | String |
|
ethertype | String |
|
protocol | String |
|
port_range_min | Integer |
|
port_range_max | Integer |
|
remote_ip_prefix | String |
|
remote_group_id | String |
|
remote_address_group_id | String |
|
tenant_id | String |
|
响应示例
{
"security_group_rule": {
"direction": "ingress",
"ethertype": "IPv4",
"id": "2bc0accf-312e-429a-956e-e4407625eb62",
"description": "",
"port_range_max": 80,
"port_range_min": 80,
"protocol": "tcp",
"remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"remote_ip_prefix": null,
"security_group_id": "a7734e61-b545-452d-a3cd-0189cbd9747a",
"tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"remote_address_group_id": null
}
} 状态码
请参见状态码。
错误码
请参考错误码。

