Grant permissions to RAM users and RAM roles

更新时间:
复制 MD 格式

You can grant different permissions to RAM users and RAM roles as needed. Only authorized RAM users and RAM roles can perform operations in the ASM console, such as creating mesh instances or updating Service Mesh feature configurations. This practice prevents security risks caused by exposing your Alibaba Cloud account's AccessKey pair. This topic uses a RAM user as an example to describe how to grant permissions.

Prerequisites

Background information

Because RAM users and RAM roles have different use cases, their permission requirements vary:

Grant system policies to RAM users and roles

ASM provides the AliyunASMReadOnlyAccess and AliyunASMFullAccess system policies by default. You can grant these policies directly. These policies are described as follows:

  • AliyunASMReadOnlyAccess

    Grants read-only permissions to manage Alibaba Cloud Service Mesh (ASM). With this policy, you can only view the status of a Service Mesh and perform other read-only operations. You cannot make changes to the Service Mesh.

  • AliyunASMFullAccess

    Grants full permissions to manage Alibaba Cloud Service Mesh (ASM). A RAM user with this policy has permissions on mesh resources equivalent to those of an Alibaba Cloud account and can perform any operation.

The following steps describe how to grant the AliyunASMReadOnlyAccess policy to a RAM user. For more information about how to grant permissions to a RAM user and a RAM role, see Manage permissions for RAM users and Manage permissions for RAM roles.

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

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

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

    image

    You can also select multiple RAM users and click Add Permissions in the lower part of the page to grant permissions to the RAM users at a time.

  4. In the Grant Permission panel, add 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 Use resource groups to manage ECS access.

    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. Under All Types, click System Policy. In the search box, enter AliyunASMReadOnlyAccess, and then click AliyunASMReadOnlyAccess.

      Note

      You can attach up to five policies at a time. To attach more policies, repeat this procedure.

    4. Click OK.

  5. Click Close.

Grant custom policies to RAM users and roles

If you need fine-grained access control, create a custom policy and then grant it to a RAM user or RAM role.

Create an access policy for a mesh instance

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

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

  3. On the Policies page, click Create Policy.

    image

  4. On the Create Policy page, click the Script Editor tab.

    image

  5. Enter the policy content and click Next to edit policy information.

    You can implement fine-grained authorization for API operations by changing the Action field in the Statement. This topic uses a restricted access policy as an example. This policy grants all RAM permissions for a Service Mesh except for RBAC authorization. A RAM user with this policy can perform all operations except for granting RBAC permissions to other users. For more information about the policy syntax and structure, see Policy structure and syntax.

    {
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "servicemesh:Add*",
                    "servicemesh:CRBatchDeletion",
                    "servicemesh:Create*",
                    "servicemesh:Delete*",
                    "servicemesh:Describe*",
                    "servicemesh:Enable*",
                    "servicemesh:Disable*",
                    "servicemesh:Get*",
                    "servicemesh:InvokeApiServer",
                    "servicemesh:List*",
                    "servicemesh:Modify*",
                    "servicemesh:Re*",
                    "servicemesh:Run*",
                    "servicemesh:Set*",
                    "servicemesh:Sync*",
                    "servicemesh:Update*",
                    "servicemesh:Upgrade*"
                ],
                "Resource": "*"
            },
            {
                "Effect": "Allow",
                "Action": [
                    "log:ListLogStores",
                    "log:ListDashboard",
                    "log:GetDashboard",
                    "log:ListSavedSearch",  
                    "log:ListProject"
                ],
                "Resource": "*"
            },
            {
                "Effect": "Allow",
                "Action": "log:GetLogStoreLogs",
                "Resource": "acs:log:*:*:project/*/logstore/audit-*"
            },
            {
                "Effect": "Allow",
                "Action": "log:GetLogStoreLogs",
                "Resource": "acs:log:*:*:project/*/logstore/istio-*"
            },
            {
                "Action": "ram:CreateServiceLinkedRole",
                "Resource": "*",
                "Effect": "Allow",
                "Condition": {
                    "StringEquals": {
                        "ram:ServiceName": "servicemesh.aliyuncs.com"
                    }
                }
            }
        ],
        "Version": "1"
    }
  6. In the Basic Information section, enter a policy name. In this example, enter ASMPolicy1, and then click OK.

Grant a custom policy to RAM users and roles

This section describes how to grant the custom policy to a RAM user. For more information about how to grant permissions to a RAM role, see Manage permissions for RAM roles.

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

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

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

    image

    You can also select multiple RAM users and click Add Permissions in the lower part of the page to grant permissions to the RAM users at a time.

  4. In the Grant Permission panel, add 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 Use resource groups to manage ECS access.

    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. Under All Types, click Custom Policy. In the search box, enter ASMPolicy1, and then click ASMPolicy1.

      Note

      You can attach up to five policies at a time. To attach more policies, repeat this procedure.

    4. Click OK.

  5. Click Close.

Custom policy examples

Scenario 1: Grant permissions for a single mesh

You can use the following policy to grant permissions to manage a single mesh instance. After this policy is granted, the RAM user or RAM role can manage only the specified mesh instance.

Note

When you create the policy, replace <ServicemeshId> in the policy with the ID of the target mesh instance.

{
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "servicemesh:*",
      "Resource": "acs:servicemesh:*:*:servicemesh/<ServicemeshId>"
    },
    {
      "Effect": "Allow",
      "Action": "servicemesh:DescribeServiceMeshes",
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": "log:GetLogStoreLogs",
      "Resource": "acs:log:*:*:project/*/logstore/audit-<ServicemeshId>"
    },
    {
      "Effect": "Allow",
      "Action": "log:GetLogStoreLogs",
      "Resource": "acs:log:*:*:project/*/logstore/istio-<ServicemeshId>"
    }
  ],
  "Version": "1"
}

Scenario 2: Grant read/write access to Istio resources

The built-in AliyunASMReadOnlyAccess system policy grants a RAM user or RAM role read-only permissions on Alibaba Cloud Service Mesh (ASM). However, a RAM user or role with this policy cannot manage Istio resources in the mesh.

You can use the following policy to grant read and write permissions for Istio resources. After this policy is granted to a RAM user or RAM role, the RAM user or RAM role can use the ASM console to manage Istio resources in the mesh, but cannot make changes to other parts of the mesh, such as feature settings.

{
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "servicemesh:List*",
                "servicemesh:Describe*",
                "servicemesh:Get*",
                "servicemesh:InvokeApiServer"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "log:ListLogStores",
                "log:ListDashboard",
                "log:GetDashboard",
                "log:ListSavedSearch"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "log:GetLogStoreLogs",
            "Resource": "acs:log:*:*:project/*/logstore/audit-*"
        }
    ],
    "Version": "1"
}

Scenario 3: Grant RBAC authorization permissions

You can use the following policy to grant permissions to perform RBAC authorization for other users or roles. After this policy is granted to a RAM user or RAM role, the RAM user or RAM role can use the ASM console to manage the RBAC permissions of other RAM roles or RAM users, but cannot view or operate any mesh instances.

{
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "servicemesh:DescribeUserPermissions",
                "servicemesh:GrantUserPermissions",
                "servicemesh:DescribeServiceMeshes",
                "servicemesh:DescribeUsersWithPermissions"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "ims:ListUserBasicInfos",
            "Resource": "*"
        }
    ],
    "Version": "1"
}