Configure permissions for data transformation jobs

Updated at:

Configure permissions for Simple Log Service (SLS) data transformation jobs so that your users can manage the jobs and each job can read source data and write transformation results.

Permissions for data transformation jobs fall into the following two categories:

  • Operation permissions — Permissions for a Resource Access Management (RAM) user to create, delete, modify, and view data transformation jobs, and to preview data in the SLS console or by using an SDK.

  • Data access permissions — Permissions for a data transformation job to read data from a source LogStore and write the results to a destination LogStore.

Grant a RAM user permissions to perform data transformation operations

These operations include creating, deleting, modifying, and viewing transformation jobs, and previewing data. Make sure you have created a RAM user. You can grant permissions in either of the following ways:

  • Use a system policy: Simple to configure but grants broad, coarse-grained permissions.

  • Use a custom policy: Grants fine-grained control over specific projects or Logstores. Recommended for strict permission requirements.

Use a system policy

  1. Log on to the Resource Access Management (RAM) console using an Alibaba Cloud account or as a RAM administrator.

  2. Attach the following system policies to the RAM user (Manage RAM user permissions):

    • AliyunRAMFullAccess

    • AliyunLogFullAccess

  3. After you save the configuration, the RAM user can:

    • Create, delete, modify, and view data transformation jobs.

    • Read data from a source Logstore to preview jobs.

Use a custom policy

  1. Log on to the RAM console by using an Alibaba Cloud account or as a RAM administrator.

  2. Create a custom policy in script mode. For example, name it log-etl-operator-policy. On the Script Editor tab, replace the content with the following template. Replace the project and LogStore names with your actual values.

    {
        "Version":"1",
        "Statement":[
            {
                "Effect":"Allow",
                "Action":[
                    "log:CreateLogStore",
                    "log:CreateIndex",
                    "log:UpdateIndex",
                    "log:Get*"
                ],
                "Resource":"acs:log:*:*:project/ProjectName/logstore/internal-etl-log"
            },
            {
                "Action":[
                    "log:List*"
                ],
                "Resource":"acs:log:*:*:project/*",
                "Effect":"Allow"
            },
            {
                "Action":[
                    "log:Get*",
                    "log:List*"
                ],
                "Resource":[
                    "acs:log:*:*:project/ProjectName/logstore/LogstoreName"
                ],
                "Effect":"Allow"
            },
            {
                "Effect":"Allow",
                "Action":[
                    "log:GetDashboard",
                    "log:CreateDashboard",
                    "log:UpdateDashboard"
                ],
                "Resource":"acs:log:*:*:project/ProjectName/dashboard/internal-etl-insight*"
            },
            {
                "Effect":"Allow",
                "Action":"log:CreateDashboard",
                "Resource":"acs:log:*:*:project/ProjectName/dashboard/*"
            },
           {
                "Effect":"Allow",
                "Action":[
                    "log:CreateETL",
                    "log:DeleteETL",
                    "log:UpdateETL",
                    "log:StartETL",
                    "log:StopETL",
                    "log:ListETLS",
                    "log:GetETL"
                ],
                "Resource":"acs:log:*:*:project/ProjectName/etl/*"
            },
            {
                "Effect": "Allow",
                "Action": [
                    "ram:PassRole",
                    "ram:GetRole",
                    "ram:ListRoles"
                ],
                "Resource": "*"
             }
        ]
    }
  3. Attach the custom policy that you created to the RAM user.

Authorize a data transformation job to access LogStore data

Write to a LogStore in the same account

When the source and destination LogStores belong to the same Alibaba Cloud account, you can grant permissions by using a default role or a custom role. A default role is simple to configure but grants only its fixed built-in permissions. A custom role gives you fine-grained control over specific projects and LogStores.

Use a default role

When you create a data transformation job, select the default role AliyunLogETLRole. The AliyunLogETLRole system role has the following built-in permissions:

  • Read data from the source LogStore.

  • Write transformation results to a destination LogStore in the same account.

Use a custom role

  1. Create a RAM role and configure a trust policy. Configure the following settings:

    • Trusted Entity Type: Alibaba Cloud Service

    • Trusted Entity Name: Simple Log Service

      After you create the role, verify that the Service field in the trust policy contains at least "log.aliyuncs.com".

  2. Grant the RAM role read-only access to the source LogStore. Create a custom policy. For example, name it log-etl-source-reader-policy. This policy grants read access to a specific source LogStore.

    On the Script Editor tab, replace the existing content with a script for exact authorization or wildcard authorization.

    Exact authorization

    In this example, the source project is log-project-prod and the source LogStore is access_log. Replace the example values with your actual values.

    {
      "Version": "1",
      "Statement": [
        {
          "Action": [
            "log:ListShards",
            "log:GetCursorOrData",
            "log:GetConsumerGroupCheckPoint",
            "log:UpdateConsumerGroup",
            "log:ConsumerGroupHeartBeat",
            "log:ConsumerGroupUpdateCheckPoint",
            "log:ListConsumerGroup",
            "log:CreateConsumerGroup"
          ],
          "Resource": [
            "acs:log:*:*:project/log-project-prod/logstore/access_log",
            "acs:log:*:*:project/log-project-prod/logstore/access_log/*"
          ],
          "Effect": "Allow"
        }
      ]
    }

    Wildcard authorization

    In this example:

    • The source projects are named log-project-dev-a, log-project-dev-b, log-project-dev-c, and so on.

    • The source LogStores are named app_a_log, app_b_log, app_c_log, and so on.

      Replace the example values with your actual values.

    {
      "Version": "1",
      "Statement": [
        {
          "Action": [
            "log:ListShards",
            "log:GetCursorOrData",
            "log:GetConsumerGroupCheckPoint",
            "log:UpdateConsumerGroup",
            "log:ConsumerGroupHeartBeat",
            "log:ConsumerGroupUpdateCheckPoint",
            "log:ListConsumerGroup",
            "log:CreateConsumerGroup"
          ],
          "Resource": [
            "acs:log:*:*:project/log-project-dev-*/logstore/app_*_log",
        "acs:log:*:*:project/log-project-dev-*/logstore/app_*_log/*"
          ],
          "Effect": "Allow"
        }
      ]
    }
  3. Attach this policy to the RAM role that you created in Step 1. For instructions, see Grant permissions to a RAM role.

  4. Grant the RAM role permissions to write data to the destination LogStore. Create a custom policy. For example, name it log-etl-target-writer-policy. This policy grants write access to the destination LogStore.

    On the Script Editor tab, replace the existing content with a script for exact authorization or wildcard authorization.

    Exact authorization

    In this example, the destination project is log-project-prod and the destination LogStore is access_log_output. Replace the example values with your actual values.

    {
      "Version": "1",
      "Statement": [
        {
          "Action": [
            "log:Post*"
          ],
          "Resource": "acs:log:*:*:project/log-project-prod/logstore/access_log_output",
          "Effect": "Allow"
        }
      ]
    }

    Wildcard authorization

    In this example:

    • The destination projects are named log-project-dev-a, log-project-dev-b, log-project-dev-c, and so on.

    • The destination LogStores are named app_a_log_output, app_b_log_output, app_c_log_output, and so on.

      Replace the example values with your actual values.

    {
      "Version": "1",
      "Statement": [
        {
          "Action": [
            "log:Post*",
            "log:BatchPost*"
          ],
           "Resource": "acs:log:*:*:project/log-project-dev-*/logstore/app_*_log_output",
          "Effect": "Allow"
        }
      ]
    }
  5. Attach this policy to the custom RAM role that you created in Step 1. For instructions, see Grant permissions to a RAM role.

Write to a LogStore in a different account

When the source and destination LogStores belong to different Alibaba Cloud accounts, you must use a custom role to grant access.

For example, to transform data from a source LogStore in Account A and write the results to a destination LogStore in Account B, log on to Account B and grant permissions as follows.

  1. Create a RAM role and configure a trust policy. Create RAM role A in Account A (the source LogStore owner) and RAM role B in Account B (the destination LogStore owner). Configure the following settings:

    • Trusted Entity Type: Alibaba Cloud Service

    • Trusted Entity Name: Simple Log Service

      After you create the roles, verify that the Service field in each trust policy contains at least "log.aliyuncs.com".

  2. Grant permissions to read data from the source LogStore. In Account A (the source LogStore owner), create a custom policy. For example, name it log-etl-source-reader-policy. This policy grants read access to a specific source LogStore.

    On the Script Editor tab, replace the existing content with a script for exact authorization or wildcard authorization.

    Exact authorization

    In this example, the source project is log-project-prod and the source LogStore is access_log. Replace the example values with your actual values.

    {
      "Version": "1",
      "Statement": [
        {
          "Action": [
            "log:ListShards",
            "log:GetCursorOrData",
            "log:GetConsumerGroupCheckPoint",
            "log:UpdateConsumerGroup",
            "log:ConsumerGroupHeartBeat",
            "log:ConsumerGroupUpdateCheckPoint",
            "log:ListConsumerGroup",
            "log:CreateConsumerGroup"
          ],
          "Resource": [
            "acs:log:*:*:project/log-project-prod/logstore/access_log",
            "acs:log:*:*:project/log-project-prod/logstore/access_log/*"
          ],
          "Effect": "Allow"
        }
      ]
    }

    Wildcard authorization

    In this example, the source projects are log-project-dev-a, log-project-dev-b, and log-project-dev-c, and the source LogStores are app_a_log, app_b_log, and app_c_log. Replace the example values with your actual values.

    {
      "Version": "1",
      "Statement": [
        {
          "Action": [
            "log:ListShards",
            "log:GetCursorOrData",
            "log:GetConsumerGroupCheckPoint",
            "log:UpdateConsumerGroup",
            "log:ConsumerGroupHeartBeat",
            "log:ConsumerGroupUpdateCheckPoint",
            "log:ListConsumerGroup",
            "log:CreateConsumerGroup"
          ],
          "Resource": [
            "acs:log:*:*:project/log-project-dev-*/logstore/app_*_log",
        "acs:log:*:*:project/log-project-dev-*/logstore/app_*_log/*"
          ],
          "Effect": "Allow"
        }
      ]
    }
  3. Attach this policy to the custom RAM role A that you created in Step 1.

  4. Grant permissions to write data to the destination LogStore. In Account B (the destination LogStore owner), create a custom policy. For example, name it log-etl-target-writer-policy. This policy grants write access to the destination LogStore.

    On the Script Editor tab, replace the existing content with a script for exact authorization or wildcard authorization.

    Exact authorization

    In this example, the destination project is log-project-prod and the destination LogStore is access_log_output. Replace the example values with your actual values.

    {
      "Version": "1",
      "Statement": [
        {
          "Action": [
            "log:Post*"
          ],
          "Resource": "acs:log:*:*:project/log-project-prod/logstore/access_log_output",
          "Effect": "Allow"
        }
      ]
    }

    Wildcard authorization

    In this example:

    • The destination projects are named log-project-dev-a, log-project-dev-b, log-project-dev-c, and so on.

    • The destination LogStores are named app_a_log_output, app_b_log_output, app_c_log_output, and so on.

      Replace the example values with your actual values.

    {
      "Version": "1",
      "Statement": [
        {
          "Action": [
            "log:Post*",
            "log:BatchPost*"
          ],
           "Resource": "acs:log:*:*:project/log-project-dev-*/logstore/app_*_log_output",
          "Effect": "Allow"
        }
      ]
    }
  5. Attach this policy to the custom RAM role B that you created in Step 1.

  6. Configure the trust policy. In Account B (the destination LogStore owner), log on to the RAM console.

  7. In the left-side navigation pane, choose Identity Management > Roles.

  8. In the RAM role list, click the destination RAM role.

  9. On the Trust Policy Management tab, click Edit Trust Policy:

    {
      "Version": "1",
      "Statement": [
        {
          "Action": "sts:AssumeRole",
          "Effect": "Allow",
          "Principal": {
            "Service": [
              "ID-of-account-A-that-owns-the-source-Logstore@log.aliyuncs.com"
            ]
          }
        }
      ]
    }
    Note
    • Replace "ID-of-account-A-that-owns-the-source-Logstore@log.aliyuncs.com" with the ID of Account A, such as 1234567890123***@log.aliyuncs.com.

    • This policy allows Account A to obtain temporary credentials from SLS to assume this role in Account B, which grants access to resources such as the destination LogStore.

    • Record the Alibaba Cloud Resource Name (ARN) of this role. You need this ARN when you create the data transformation job in Account A.