Function
A security group has inbound and outbound rules to control traffic that is allowed to reach or leave the instances associated with the security group.
URI
POST /v3/{project_id}/vpc/security-group-rules
Table 1 Path ParametersParameter
|
Mandatory
|
Type
|
Description
|
project_id
|
Yes
|
String
|
|
Request Parameters
Table 2 Request body parametersParameter
|
Mandatory
|
Type
|
Description
|
dry_run
|
No
|
Boolean
|
|
security_group_rule
|
Yes
|
CreateSecurityGroupRuleOption object
|
|
Table 3 CreateSecurityGroupRuleOptionParameter
|
Mandatory
|
Type
|
Description
|
security_group_id
|
Yes
|
String
|
|
description
|
No
|
String
|
|
direction
|
Yes
|
String
|
|
ethertype
|
No
|
String
|
|
protocol
|
No
|
String
|
|
multiport
|
No
|
String
|
Definition: Port range of a security group rule.
Constraints: The port number ranges from 1 to 65535.
Range: The value can be a single port (80), a port range (1-30), or inconsecutive ports separated by commas (22,3389,80).
Default Value: None
|
remote_ip_prefix
|
No
|
String
|
Definition: Remote IP address of a security group rule. If direction is set to egress, this address is the outbound destination and will be accessed by instances in the security group. If direction is set to ingress, this address is the inbound source and will access instances in the security group.
Constraints:
This parameter is mutually exclusive with parameters remote_group_id and remote_address_group_id.
Range:
IP address. If an IP address is transferred in the request, the IP address is automatically formatted with /32 as the subnet mask, for example, 192.168.21.45/32.
The value must be in CIDR format.
Default Value: None
|
remote_group_id
|
No
|
String
|
Definition: ID of the remote security group of a security group rule. If the action of the rule is allow, the traffic from the remote security group is allowed. If the action of the rule is deny, the traffic from the remote security group is denied.
Constraints: This parameter is mutually exclusive with parameters remote_ip_prefix and remote_address_group_id.
Range: ID of an existing security group.
Default Value: None
|
remote_address_group_id
|
No
|
String
|
Definition: ID of the remote IP address group of a security group rule.
Constraints: The parameter is mutually exclusive with parameters remote_ip_prefix and remote_group_id.
Range: ID of an existing IP address group.
Default Value: None
|
action
|
No
|
String
|
|
priority
|
No
|
String
|
|
Response Parameters
Status code: 201
Table 4 Response body parametersParameter
|
Type
|
Description
|
request_id
|
String
|
Definition: Request ID.
Range: None
|
security_group_rule
|
SecurityGroupRule object
|
|
Table 5 SecurityGroupRuleParameter
|
Type
|
Description
|
id
|
String
|
Definition: ID of a security group rule. After a security group rule is created, a security group rule ID is generated, which uniquely identifies the security group rule.
Range: The value is in UUID format with hyphens (-).
|
description
|
String
|
|
security_group_id
|
String
|
|
direction
|
String
|
|
protocol
|
String
|
|
ethertype
|
String
|
|
multiport
|
String
|
Definition: Port range of a security group rule.
Range: The value can be a single port (80), a port range (1-30), or inconsecutive ports separated by commas (22,3389,80).
|
action
|
String
|
|
priority
|
Integer
|
|
remote_group_id
|
String
|
Definition: ID of the remote security group of a security group rule. If the action of the rule is allow, the traffic from the remote security group is allowed. If the action of the rule is deny, the traffic from the remote security group is denied.
Range: ID of an existing security group.
|
remote_ip_prefix
|
String
|
Definition: Remote IP address of a security group rule.
If direction is set to egress, the IP address is the outbound destination and will be accessed by instances in the security group.
If direction is set to ingress, the IP address is the inbound source and will access the instances in the security group.
Range: CIDR notation format. If an IP address is transferred in the request, the IP address is automatically formatted with /32 as the subnet mask, for example, 192.168.21.45/32.
|
remote_address_group_id
|
String
|
|
created_at
|
String
|
|
updated_at
|
String
|
|
project_id
|
String
|
|
Status code: 202
Table 6 Response body parametersParameter
|
Type
|
Description
|
request_id
|
String
|
Definition: Request ID.
Range: None
|
error_msg
|
String
|
|
error_code
|
String
|
Definition: Error code.
Range: None
|
Example Requests
Create an inbound rule in the security group whose ID is 0552091e-b83a-49dd-88a7-4a5c86fd9ec3.
POST https://{Endpoint}/v3/{project_id}/vpc/security-group-rules
{
"security_group_rule" : {
"security_group_id" : "0552091e-b83a-49dd-88a7-4a5c86fd9ec3",
"direction" : "ingress",
"protocol" : "tcp",
"description" : "security group rule description",
"action" : "allow",
"priority" : 1,
"multiport" : "33",
"remote_ip_prefix" : "10.10.0.0/16"
}
}
Example Responses
Status code: 201
Normal response to the POST operation. For more status codes, see Status Codes.
{
"request_id" : "1666b2708aaf849337572d6846dce781",
"security_group_rule" : {
"id" : "f626eb24-d8bd-4d26-ae0b-c16bb65730cb",
"project_id" : "060576782980d5762f9ec014dd2f1148",
"security_group_id" : "0552091e-b83a-49dd-88a7-4a5c86fd9ec3",
"direction" : "ingress",
"protocol" : "tcp",
"description" : "security group rule description",
"created_at" : "2020-08-13T07:12:36.000+00:00",
"updated_at" : "2020-08-13T07:12:36.000+00:00",
"ethertype" : "IPv4",
"remote_ip_prefix" : "10.10.0.0/16",
"multiport" : 33,
"action" : "allow",
"priority" : 1,
"remote_group_id" : null,
"remote_address_group_id" : null
}
}
Status code: 202
Normal response for the specified pre-check request of API V3. For more status codes, see Status Code.
{
"error_msg" : "Request validation has been passed with dry run...",
"error_code" : "SYS.0202",
"request_id" : "cfd81aea3f59eac7128dba4b36d516c8"
}
Status Codes
Status Code
|
Description
|
201
|
Normal response to the POST operation. For more status codes, see Status Codes.
|
202
|
Normal response for the specified pre-check request of API V3. For more status codes, see Status Code.
|