Help Center/ TaurusDB/ User Guide/ Permissions Management/ GaussDB(for MySQL) Custom Policies
Updated on 2025-03-28 GMT+08:00

GaussDB(for MySQL) Custom Policies

Custom policies can be created to supplement the system policies of GaussDB(for MySQL).

You can create a custom policy in either of the following ways:

  • Visual editor: Select cloud services, actions, resources, and request conditions. This does not require knowledge of policy syntax.
  • JSON: Write policies from scratch or based on an existing policy.

The following lists examples of common GaussDB(for MySQL) custom policies.

Example Custom Policies

  • Example 1: Allowing users to create GaussDB(for MySQL) instances
    {
        "Version": "1.1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "gaussdb:instance:create"
                ]
            }
        ]
    }
  • Example 2: Denying GaussDB(for MySQL) instance deletion

    A policy with only "Deny" permissions must be used in conjunction with other policies. If the permissions assigned to a user contain both "Allow" and "Deny", the "Deny" permissions take precedence over the "Allow" permissions.

    The following method can be used if you need to assign permissions of the GaussDB FullAccess policy to a user but you want to prevent the user from deleting GaussDB(for MySQL) instances. Create a custom policy for denying GaussDB(for MySQL) instance deletion, and attach both policies to the group the user belongs to. Then, the user can perform all operations on GaussDB(for MySQL) instances except deleting them. The following is an example of a deny policy:

    {
        "Version": "1.1",
        "Statement": [
            {
              "Effect": "Deny"
              "Action": [
                    "gaussdb:instance:delete"
                ],
              }
        ]
    }
  • Example 3: Defining permissions for multiple services in a policy

    A custom policy can contain the actions of one or multiple services that are of the same type (global or project-level). The following is an example policy containing actions of multiple services:

    {  
            "Version": "1.1",  
            "Statement": [  
                    {  
                            "Action": [  
                                    "gaussdb:instance:create",  
                                    "gaussdb:instance:modify",  
                                    "gaussdb:instance:delete",  
                     "vpc:publicIps:list",  
                     "vpc:publicIps:update"  
                            ],  
                            "Effect": "Allow"  
                    }  
            ]  
    }
  • Example 4: Allowing users to manage specified instances and some functions of instances

    Assume that your account has multiple instances and you are a database administrator. If you want to allow users to manage specified instances and some functions of instances, you can create the following permission policy.

    {
        "Version": "1.1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "gaussdb:instance:restart",
                    "gaussdb:instance:modify"
                ],
                "Resource": [
                   "GAUSSDB:*:*:instance:test*"
                ]
            },
            {
                "Effect": "Allow",
                "Action": [
                    "gaussdb:param:list",
                    "gaussdb:tag:list",
                    "gaussdb:backup:list",
                    "gaussdb:instance:create",
                    "gaussdb:instance:list"
                ]
            }
        ]
    }
    
    • Users granted these permissions can view all instances, but can manage only authorized instances. In addition, the database administrator can still use APIs to directly manage these instances. Users granted the permissions can only reboot and modify all instances under this account.
    • test* is an example of an instance name for fuzzy match and is mandatory in the permission policy. Otherwise, the authorized users cannot view any instance on the console.