Grant cluster and cloud resource access with RAM

更新时间:
复制 MD 格式

By default, RAM users and RAM roles do not have permission to call the API operations of cloud services. Grant permission to a RAM user or RAM role by using a system or custom policy before calling ACK API operations. This topic describes how to grant RAM users and RAM roles access to clusters and cloud resources.

Grant permissions with a system policy

A system policy controls read and write access to global resources. If a RAM user or RAM role needs to manage all clusters in your Alibaba Cloud account, use a system policy for quick authorization. The following table lists common system policies for ACK.

Important

System policies that grant full access contain high-risk permissions. To avoid security risks, grant these policies with caution.

Common ACK system policies

System policy name

Description

AliyunCSFullAccess

Grants a RAM user or RAM role permission to call all ACK API operations.

Note

This system policy grants only RAM permission for ACK. To perform operations management for applications in an ACK cluster, you must also configure RBAC authorization. For more information, see RBAC authorization.

AliyunVPCReadOnlyAccess

Allows a RAM user or RAM role to select a specific VPC when creating a cluster.

AliyunECSReadOnlyAccess

Allows a RAM user or RAM role to add existing nodes to a cluster or view node details.

AliyunContainerRegistryFullAccess

Allows a RAM user or RAM role to manage all container images within an Alibaba Cloud account.

AliyunLogReadOnlyAccess

Allows a RAM user or RAM role to select an existing Log Service project to store audit logs when creating a cluster, or to view the configuration inspection results of a specific cluster.

AliyunAHASReadOnlyAccess

Allows a RAM user or RAM role to use the cluster topology feature.

AliyunRAMFullAccess

Allows a RAM user or RAM role to manage all authorizations in an Alibaba Cloud account.

AliyunYundunSASReadOnlyAccess

Allows a RAM user or RAM role to view runtime security monitoring data for a cluster.

AliyunARMSReadOnlyAccess

Allows a RAM user or RAM role to view the status of the Managed Service for Prometheus for a cluster.

AliyunKMSReadOnlyAccess

Allows a RAM user or RAM role to enable secret encryption at rest when creating an ACK managed Pro cluster.

AliyunESSReadOnlyAccess

Allows a RAM user or RAM role to perform node pool operations, such as viewing, editing, and scaling.

Note

An Alibaba Cloud account has full administrative permissions on all resources within the account. Alternatively, create a RAM user and grant the AdministratorAccess permission to make the user an account administrator. This administrator can manage all cloud resources in the account. For more information, see Create a RAM user as an account administrator.

  1. Log on to the RAM console as a RAM administrator.

  2. In the left-side navigation pane, choose Identities > Users.

  3. On the Users page, find the target RAM user, and click Add Permissions in the Actions column.

    image

    Alternatively, select multiple RAM users and click Add Permissions in the lower part of the page to grant permissions to multiple RAM users at once.

  4. In the Grant Permissions panel, grant permissions to the RAM user.

    1. Configure the Resource Scope parameter.

      • Account: The authorization takes effect on the current Alibaba Cloud account.

      • Resource Group: The authorization takes effect on a specific resource group.

        Important

        If you select Resource Group for the Resource Scope parameter, make sure that the required cloud service supports resource groups. For more information, see Services that work with Resource Group. For more information about how to grant permissions on a resource group, see Control access to ECS instances with resource groups.

    2. Configure the Principal parameter.

      The principal is the RAM user to which you want to grant permissions. The current RAM user is automatically selected.

    3. Select the system policies to attach.

    4. Click OK.

  5. Click Close.

Grant permissions with a custom policy

A custom policy provides fine-grained access control over cloud resources. For example, a custom policy can restrict a user's permissions on a specific cluster. Custom policies can also control permissions at the API level, which is useful for SDK-based custom development. For more information about the authorization items supported by RAM, see Authorization information.

Note

Before creating a custom policy, familiarize yourself with the basic structure and syntax of the policy language. For more information, see Basic elements of a policy.

Step 1: Create a custom policy

  1. Sign in to the RAM console as a RAM administrator.

  2. In the left-side navigation pane, choose Permissions > Policies.

  3. On the Policies page, click Create Policy.

    image

  4. On the Create Policy page, click the JSON Editor tab and enter the policy document.

    Replace YOUR_CLUSTER_ID with the ID of your target cluster.
    {
        "Statement": [
            {
                "Action": [
                    "cs:Get*",
                    "cs:List*",
                    "cs:Describe*",
                    "cs:ScaleCluster",
                    "cs:DeleteCluster"
                ],
                "Effect": "Allow",
                "Resource": [
                    "acs:cs:*:*:cluster/YOUR_CLUSTER_ID"
                ]
            }
        ],
        "Version": "1"
    }

    Parameter

    Description

    Action

    The permissions to grant. Wildcard characters (*) are supported.

    Resource

    • Grant permissions on a single cluster

      "Resource": [
           "acs:cs:*:*:cluster/YOUR_CLUSTER_ID"
       ]
    • Grant permissions on multiple clusters

      "Resource": [
           "acs:cs:*:*:cluster/YOUR_CLUSTER_ID_1",
           "acs:cs:*:*:cluster/YOUR_CLUSTER_ID_2"
       ]
    • Grant permissions on all clusters

      "Resource": [
           "*"
       ]
  5. On the Create Policy page, click OK.

  6. In the Create Policy dialog box, enter a Policy Name and a Comment, and then click OK.

Step 2: Grant the custom policy

The steps for attaching a custom policy are the same as those for a system policy. When prompted to select a policy, choose the custom policy you created. For more information, see Grant permissions with a system policy.

Custom policy examples

Example 1: Grant read-only permission on a cluster

{
    "Statement": [
        {
            "Action": [
                "cs:Get*",
                "cs:List*",
                "cs:Describe*"
            ],
            "Effect": "Allow",
            "Resource": [
                "acs:cs:*:*:cluster/YOUR_CLUSTER_ID"
            ]
        }
    ],
    "Version": "1"
}

Example 2: Grant OSS bucket read permission

Replace YOUR_OSS_BUCKET_NAME with the name of your target OSS bucket.
{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                      "oss:ListBuckets",
                      "oss:GetBucketStat",
                      "oss:GetBucketInfo",
                      "oss:GetBucketTagging",
                      "oss:GetBucketAcl" 
                      ],    
            "Resource": "acs:oss:*:*:*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "oss:ListObjects",
                "oss:GetBucketAcl"
            ],
            "Resource": "acs:oss:*:*:YOUR_OSS_BUCKET_NAME"
        },
        {
            "Effect": "Allow",
            "Action": [
                "oss:GetObject",
                "oss:GetObjectAcl"
            ],
            "Resource": "acs:oss:*:*:YOUR_OSS_BUCKET_NAME/*"
        }
    ]
}

Example 3: Grant permissions for non-cluster-scoped APIs

Some OpenAPI operations, such as DescribeEvents, do not support cluster-specific authorization. To grant a RAM user or RAM role permissions for these operations, omit the cluster ID from the Resource field. The following table compares the original and modified RAM policies:

Before

After

{
    "Statement": [
        {
            "Action": [
                "cs:Get*",
                "cs:List*",
                "cs:Describe*"
            ],
            "Effect": "Allow",
            "Resource": [
                "acs:cs:*:*:cluster/YOUR_CLUSTER_ID"
            ]
        }
    ],
    "Version": "1"
}
{
    "Statement": [
        {
            "Action": [
                "cs:DescribeEvents"
            ],
            "Effect": "Allow",
            "Resource": [
              "*"
            ]
        },
        {
            "Action": [
                "cs:Get*",
                "cs:List*",
                "cs:Describe*"
            ],
            "Effect": "Allow",
            "Resource": [
                "acs:cs:*:*:cluster/YOUR_CLUSTER_ID"
            ]
        }
    ],
    "Version": "1"
}

Next steps