全部产品
Search
文档中心

日志服务:授权RAM用户操作CloudLens for RDS

更新时间:Dec 16, 2024

本文介绍如何授予RAM用户操作CloudLens for RDS的权限。

前提条件

已创建RAM用户。具体操作,请参见创建RAM用户

背景信息

您可以通过如下两种方式给RAM用户授予CloudLens for RDS的操作权限。

  • 系统权限策略:权限范围较大,用户无法修改系统权限策略的内容,但配置步骤简单。

  • 自定义权限策略:权限范围更精细,用户可以修改自定义权限策略的内容,配置步骤比系统权限策略更复杂。

系统权限策略

  1. 使用阿里云账号(主账号)或RAM管理员登录RAM控制台

  2. 为RAM用户授予日志服务的只读权限AliyunLogReadOnlyAccess或管理权限AliyunLogFullAccess。具体操作,请参见为RAM用户授权

自定义权限策略

  1. 使用阿里云账号(主账号)或RAM管理员登录RAM控制台

  2. 创建自定义权限策略。

    您可以授予RAM用户使用CloudLens for RDS只读权限读写权限

    只读权限

    只允许查看CloudLens for RDS中的各个页面。

    创建权限策略页面,单击脚本编辑页签,并使用以下脚本替换配置框中的原有内容。具体操作,请参见通过脚本编辑模式创建自定义权限策略

    {
        "Statement": [
           {
                "Action": [
                    "rds:DescribeSqlLogInstances"
                ],
                "Resource": "*",
                "Effect": "Allow"
            },
            {
                "Action": [
                    "log:GetLogStore",
                    "log:ListLogStores",
                    "log:GetIndex",
                    "log:GetLogStoreHistogram",
                    "log:GetLogStoreLogs",
                    "log:GetDashboard",
                    "log:ListDashboard",
                    "log:ListSavedSearch",
                    "log:GetProjectLogs"
                ],
                "Resource": [
                    "acs:log:*:*:project/*/logstore/*",
                    "acs:log:*:*:project/*/dashboard/*",
                    "acs:log:*:*:project/*/savedsearch/*"
                ],
                "Effect": "Allow"
            },
            {
                "Action": "log:GetProductDataCollection",
                "Resource": [
                    "acs:log:*:*:project/*/logstore/*",
                    "acs:rds:*:*:dbinstance/*"
                ],
                "Effect": "Allow"
            },
            {
                "Action": "log:ListProject",
                "Resource": "acs:log:*:*:project/*",
                "Effect": "Allow"
            }
        ],
        "Version": "1"
    }

    读写权限

    允许操作CloudLens for RDS中的各个功能。

    创建权限策略页面,单击脚本编辑页签,并使用以下脚本替换配置框中的原有内容。具体操作,请参见通过脚本编辑模式创建自定义权限策略

    {
        "Statement": [
            {
                "Action": [
                    "rds:DescribeSqlLogInstances",
                    "rds:DisableSqlLogDistribution",
                    "rds:EnableSqlLogDistribution",
                    "rds:ModifySQLCollectorPolicy"
                ],
                "Resource": "*",
                "Effect": "Allow"
            },
            {
                "Action": [
                    "log:GetLogStore",
                    "log:CreateProject",
                    "log:ListLogStores",
                    "log:GetIndex",
                    "log:GetLogStoreHistogram",
                    "log:GetLogStoreLogs",
                    "log:GetDashboard",
                    "log:ListDashboard",
                    "log:ListSavedSearch",
                    "log:CreateLogStore",
                    "log:CreateIndex",
                    "log:UpdateIndex",
                    "log:ListLogStores",
                    "log:GetLogStore",
                    "log:GetLogStoreLogs",
                    "log:CreateDashboard",
                    "log:CreateChart",
                    "log:UpdateDashboard",
                    "log:UpdateLogStore",
                    "log:GetProjectLogs"
                ],
                "Resource": [
                    "acs:log:*:*:project/*/"
                ],
                "Effect": "Allow"
            },
            {
                "Action": [
                    "log:GetProductDataCollection",
                    "log:OpenProductDataCollection",
                    "log:CloseProductDataCollection"
                ],
                "Resource": [
                    "acs:log:*:*:project/*/logstore/*",
                    "acs:rds:*:*:dbinstance/*"
                ],
                "Effect": "Allow"
            },
            {
                "Action": [
                    "log:SetGeneralDataAccessConfig"
                ],
                "Resource": [
                    "acs:log:*:*:resource/sls.general_data_access.rds.global_conf.*/record"
                ],
                "Effect": "Allow"
            },
            {
                "Action": "ram:CreateServiceLinkedRole",
                "Resource": "*",
                "Effect": "Allow",
                "Condition": {
                    "StringEquals": {
                        "ram:ServiceName": "audit.log.aliyuncs.com",
                        "ram:ServiceName": "rds.aliyuncs.com"
                    }
                }
            },
            {
                "Action": "log:ListProject",
                "Resource": "acs:log:*:*:project/*",
                "Effect": "Allow"
            }
        ],
        "Version": "1"
    }
  3. 为RAM用户添加创建的自定义权限策略。具体操作,请参见为RAM用户授权