Creating a Custom Policy

Custom policies can be created as a supplement to the system policies of DLI. You can add actions to custom policies. For the actions supported for custom policies, see "Permissions Policies and Supported Actions" in the Elastic Volume Service API Reference.

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

. This section describes common DLI custom policies.

Policy Field Description

The following example assumes that the authorized user has the permission to create tables in all databases in all regions:

{
    "Version": "1.1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "dli:database:createTable"
            ],
            "Resource": [
                "dli:*:*:database:*"
            ]
        }
    ]
}

Creating a Custom Policy

You can set actions and resources of different levels based on scenarios.

  1. Define an action.

    The format is Service name:Resource type:Action. The wildcard is *. Example:

    Table 2 Action

    Action

    Description

    dli:queue:submit_job

    Submission operations on a DLI queue

    dli:queue:*

    All operations on a DLI queue

    dli:*:*

    All operations on all DLI resource types

    For more information about the relationship between operations and system permissions, see Common Operations Supported by DLI System Policy.

  2. Define a resource.

    The format is Service name:Region:Domain ID:Resource type:Resource path. The wildcard (*) indicates all resources. The five fields can be flexibly set. Different levels of permission control can be set for resource paths based on scenario requirements. If you need to set all resources of the service, you do not need to specify this field. For details about the definition of Resource, see Table 3. For details about the resource types and paths in Resource, see Table 4.

    Table 3 Resource

    Resource

    Description

    DLI:*:*:table:databases.dbname.tables.*

    DLI, any region, any account ID, all table resources of database dbname

    DLI:*:*:database:databases.dbname

    DLI, any region, any account ID, resource of database dbname

    DLI:*:*:queue:queues.*

    DLI, any region, any account ID, any queue resource

    DLI:*:*:jobs:jobs.flink.1

    DLI, any region, any account ID, Flink job whose ID is 1

    Table 4 DLI resources and their paths

    Resource Type

    Resource Names

    Path

    queue

    DLI queue

    queues.queuename

    database

    DLI database

    databases.dbname

    table

    DLI table

    databases.dbname.tables.tbname

    column

    DLI column

    databases.dbname.tables.tbname.columns.colname

    jobs

    DLI Flink job

    jobs.flink.jobid

    resource

    DLI package

    resources.resourcename

    group

    DLI package group

    groups.groupname

    datasourceauth

    DLI cross-source authentication information

    datasourceauth.name

    edsconnections

    Enhanced datasource connection

    edsconnections.connection ID

  3. Combine all the preceding fields into a JSON file to form a complete policy. You can set multiple actions and resources. You can also create a policy on the visualized page provided by IAM. For example:

    Create a policy that grants users the permission to create and delete databases, submit jobs for any queue, and delete tables under any account ID in any region of DLI.

    {
        "Version": "1.1",
        "Statement": [
            {
                "Effect": " Allow",
                "Action": [
                      "dli:database:createDatabase",
                      "dli:database:dropDatabase",
                      "dli:queue:submitJob",
                      "dli:table:dropTable"
                ],
                "Resource": [
                      "dli:*:*:database:*",
                      "dli:*:*:queue:*",
                      "dli:*:*:table:*"
                ]
            }
        ]
    }

Example Custom Policies