Updated on 2022-09-27 GMT+08:00

Creating a Custom Policy

Custom policies can be created to supplement the system-defined policies of CDN. For the actions that can be added to custom policies, see Permissions Policies and Supported Actions.

You can create custom policies in either of the following two 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 common custom CCE policies.

Example Custom Policies

  • Example 1: Allowing users to create acceleration domain names
{
    "Version": "1.1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "cdn:configuration:createDomains"
            ]
        }
    ]
}
  • Example 2: Allowing users to set an IP blacklist
{
        "Version": "1.1",
        "Statement": [
                {
                        "Action": [
                                "cdn:configuration:modifyIpAcl"
                        ],
                        "Effect": "Allow"
                }
        ]
}
  • Example 3: Denying users to delete acceleration domain names.

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

    The following method can be used if you need to assign permissions of the CDN Admin policy to a user but also forbid the user from deleting acceleration domain names. Create a custom policy for denying acceleration domain name deletion, and assign both policies to the group the user belongs to. Then the user can perform all operations on CDN except deleting acceleration domain names. The following is an example deny policy:

    {
            "Version": "1.1",
            "Statement": [
                    {
                            "Action": [
                                    "cdn:configuration:deleteDomains"
                            ],
                            "Effect": "Deny"
                    }
            ]
    }
  • Example 4: Defining permissions for multiple services in a policy

    A custom policy can contain the actions of multiple services that are 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": [
                    "cdn:configuration:enableDomains",
                    "cdn:configuration:createDomains",
                    "scm:cert:get",
                    "scm:certProduct:get",
                    "scm:certType:get"
                ]
            }
        ]
    }