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

CCI Custom Policies

You can create custom policies to supplement the system-defined policies of CCI. 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 ways:

  • Visual editor: Select a cloud service, specify actions and resources, and add request conditions. You do not need to have knowledge of JSON syntax.
  • JSON: Create a policy in the JSON format from scratch or based on an existing policy.

The following provides some example custom policies of CCI.

Example Custom Policies

  • Example 1: Updating a namespace
    {
        "Version": "1.1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "cci:namespace:update"
                ]
            }
        ]
    }
  • Example 2: Denying namespace deletion

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

    The following method can be used if you need to assign permissions of the CCIFullAccess policy to a user but you want to prevent the user from deleting namespaces (cci:namespace:delete). Create a custom policy for denying namespace deletion, and attach both policies to the group to which the user belongs. Then, the user can perform all operations on CCI except deleting namespaces. The following is an example of a deny policy:

    {
        "Version": "1.1",
        "Statement": [
            {
                "Action": [
                    "cci:namespace:delete"
                ],
                "Effect": "Deny"
            }
        ]
    }
  • Example 3: 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": [
            {
                "Action": [
                    "ecs:cloudServers:resize",
                    "ecs:cloudServers:delete",
                    "ecs:cloudServers:delete",
                    "ims:images:list",
                    "ims:serverImages:create"
                ],
                "Effect": "Allow"
            }
        ]
    }