Help Center/ GaussDB(DWS)/ User Guide/ Preparations/ Creating a GaussDB(DWS) Custom Policy
Updated on 2024-10-21 GMT+08:00

Creating a GaussDB(DWS) Custom Policy

Custom policies can be created as a supplement to the system policies of GaussDB(DWS). For details about the custom policy actions, see Permissions Policies and Supported Actions.

You can create custom policies in either of the following ways:

  • Visual editor: Select cloud services, actions, resources, and request conditions without the need to know policy syntax.
  • JSON: Edit JSON policies from scratch or based on an existing policy.

For details, see Creating a Custom Policy. This section provides examples of GaussDB(DWS) custom policies.

Custom Policy Examples

  • Example 1: allowing users to create/restore, restart, and delete a cluster, configure security parameters, and reset passwords
    {
          "Version": "1.1",
          "Statement": [
                {
                      "Effect": "Allow",
                      "Action": [
                            "dws:cluster:create",
                            "dws:cluster:restart",
                            "dws:cluster:delete",
                            "dws:cluster:setSecuritySettings",
                            "dws:cluster:resetPassword",
                            "dws:*:list*",
                            "dws:*:get*",
                            "tms:predefineTags:list"
                            "ecs:*:get*",
                            "ecs:*:list*",
                            "elb:*:list*",
                            "ecs:*:create*",
                            "ecs:*:delete*",
                            "vpc:*:get*",
                            "vpc:*:list*",
                            "vpc:*:create*",
                            "vpc:*:delete*",
                            "evs:*:get*",
                            "evs:*:list*",
                            "evs:*:create*",
                            "evs:*:delete*"
                      ]
                }
          ]
    }
  • Example 2: using wildcard character (*)
    For example, the following policy has all operation permissions on GaussDB(DWS) snapshots.
    {
          "Version": "1.1",
          "Statement": [
                {
                      "Effect": "Allow",
                      "Action": [
                            "dws:snapshot:*",
                            "dws:cluster:list",
                            "dws:openAPISnapshot:detail",
                            "dws:cluster:getDetail",
                            "ecs:*:get*",
                            "ecs:*:list*",
                            "vpc:*:get*",
                            "vpc:*:list*"
                      ]
                }
          ]
    }
  • Example 3: denying cluster deletion

    A deny policy must be used in conjunction with other policies to take effect. 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(DWS) FullAccess policy to a user but also forbid the user from deleting clusters. Create a custom policy for denying cluster deletion, and assign both policies to the group the user belongs to. Then the user can perform all operations on GaussDB(DWS) except deleting clusters. The following is an example of a deny policy:

    { 
          "Version": "1.1", 
          "Statement": [ 
               {
                    "Effect": "Allow",
                    "Action": [
                         "dws:*:list*",
                         "dws:*:get*"
                     ]
                },
                { 
    		  "Effect": "Deny", 
                      "Action": [ 
                            "dws:cluster:delete"
                      ] 
                } 
          ] 
    }
  • Example 4: defining multiple actions in a policy

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

    {  
             "Version": "1.1",  
             "Statement": [  
                     {  
                     "Effect": "Allow",
                     "Action": [  
                            "dws:cluster:create",
                            "dws:cluster:restart",
                            "dws:cluster:setSecuritySettings",
                            "dws:*:get*",
                            "dws:*:list*",
                            "tms:predefineTags:list",
                            "elb:*:list*",
                            "ecs:*:get*",
                            "ecs:*:list*",
                            "ecs:*:create*",
                            "vpc:*:get*",
                            "vpc:*:list*",
                            "vpc:*:create*",
                            "evs:*:get*",
                            "evs:*:list*",
                            "evs:*:create*"
                      ]
                     },
                    { 
    		  "Effect": "Deny", 
                      "Action": [ 
                            "dws:cluster:delete"
                      ] 
                    } 
    
             ]  
     }