Updated on 2024-08-07 GMT+08:00

Querying Security Group Rule Changes

Scenarios

CTS records the changes made to security group rules. You can query the change details of:
  • New security group rules
  • Modified security group rules
  • Deleted security group rules

Precautions

  • To use CTS to record security group rule changes, you need to enable CTS first.
  • CTS records operations performed on each cloud service. You can query specific operations by trace name, resource type, or operation time. Table 1 lists the operations on security group rules supported by CTS.
    Table 1 Operations on security group rules supported by CTS

    Operation

    Trace Name

    Resource Type

    Adding a security group rule

    createSecurity-group-rule

    security-group-rules

    Modifying a security group rule

    updateSecurity-group-rule

    security-group-rules

    Deleting a security group rule

    deleteSecurity-group-rule

    security-group-rules

Procedure

The following describes how to view the rule described in Table 2 that is added to security group Sg-A.
Table 2 The new security group rule

Direction

Action

Type

Protocol & Port

Source

Last Modified

Inbound

Allow

IPv4

TCP: 23

10.0.0.0/16

June 19, 2024 10:46:07 GMT+08:00

  1. Log in to the CTS console, search for the operations by trace name (createSecurity-group-rule in this example) and locate the specific operation by operation time.

    For details, see Querying Real-Time Traces.

    Figure 1 The trace list for new security group rules
  2. In the trace list, locate the target trace and click its name.

    On the Trace Overview page, you can view the details about the operation. Table 3 provides the detailed information about the operation, including operator ID and details about the security group rules.

    The trace details in Table 3 are only for your reference. The actual information may vary.

    Table 3 The trace details for the new security group rule

    Example Command Output

    Description

    "source_ip": "124.71.XX.146",

    IP address of the client that performs the operation. If this parameter is left blank, the operation is performed by the system. In this example, the IP address is 124.71.XX.146.

      "user": {
        "access_key_id": "HSTA205XXXXXC4MHAE",
        "account_id": "3c24f6f885294XXXXX93ce075fbd",
        "user_name": "cts-test-01",
        "domain": {
          "name": "cts-test",
          "id": "3c24f6f885294XXXXX93ce075fbd"
        },
      "name": "cts-test-01",
      "principal_is_root_user": "false",
      "id": "a26ee7e7224XXXXXe4a28a9ce503",
    Account of the operator who performs the operation. Key parameters are described as follows:
    • name under domain: indicates the account name. In this example, the account name is cts-test.
    • id under domain: indicates the account ID. In this example, the ID is 3c24f6f885294XXXXX93ce075fbd.
    • name: IAM username. In this example, the username is cts-test-01, which is an IAM user under account cts-test.
    • id: IAM user ID. In this example, the ID is a26ee7e7224XXXXXe4a28a9ce503.

    For details about more parameters of CTS traces, see the response parameter description in Trace Structure.

    "response": "{\"request_id\":\"8d2d1111cafaXXX9b49d53e2da38f\",\"security_group_rules\":[{\"id\":\"b6acda6e-0976-XXXX-82bc-a8093cbd591d\",\"project_id\":\"15289aca74eXXXa37dea0315d99\",\"security_group_id\":\"3730d371-3111-4ace-XXXX-b00b7259e178\",\"remote_group_id\":null,\"direction\":\"ingress\",\"protocol\":\"tcp\",\"description\":\"\",\"created_at\":\"2024-06-19T02:46:07Z\",\"updated_at\":\"2024-06-19T02:46:07Z\",\"ethertype\":\"IPv4\",\"remote_ip_prefix\":\"10.0.0.0/16\",\"multiport\":\"23\",\"remote_address_group_id\":null,\"action\":\"allow\",\"priority\":1}]}",
    Details about the security group rule in response. Key parameters are described as follows:
    • direction: indicates the direction of the security group rule. ingress indicates the inbound direction, and egress indicates the outbound direction. In this example, ingress is returned, indicating an inbound rule is added.
    • protocol: indicates the protocol of the security group rule. In this example, the protocol is TCP.
    • ethertype: indicates the source IP address version. In this example, the version is IPv4.
    • remote_ip_prefix: indicates the source or destination of the security group rule. In this example, an inbound rule is added, so this parameter indicates IP address range 10.0.0.0/16.
    • multiport: indicates the port used to filter traffic. In this example, the port is 23.
    • action: indicates whether to allow or deny traffic. allow indicates traffic is allowed, while deny indicates traffic is denied. In this example, the action is allow.
    • priority: indicates the priority of the security group rule. In this example, the priority is 1.