All Products
Search
Document Center

Realtime Compute for Apache Flink:Use a RAM role to access cloud resources (Beta)

Last Updated:Aug 27, 2026

Realtime Compute for Apache Flink supports referencing RAM roles in namespaces. By assuming a RAM role, jobs use temporary STS tokens instead of plaintext AccessKey pairs to access Alibaba Cloud resources. This enables credential-free access, fine-grained permission control, and maintenance-free credential management.

Overview

By referencing a RAM role, you can use the role to access other Alibaba Cloud services, such as OSS and KMS, from Flink jobs, without exposing plaintext AccessKey pairs in the job code.

Key benefits:

  • Sensitive information protection: No AccessKey pairs are exposed in jobs. The RAM role STS token replaces static credentials.

  • Fine-grained permission control: RAM role permission policies are customizable. Different connectors can use different roles to enforce the principle of least privilege.

  • Maintenance-free credentials: STS tokens are automatically obtained and renewed by the system, with no need to manage credential rotation.

For details, see Appendix: STS invocation flow.

Notes

Incorrectly deleting or modifying the permissions and trust policy of a RAM role in RAM may cause Flink jobs to fail because they cannot access cloud resources. According to the Service Level Agreement for Realtime Compute for Apache Flink, unavailability caused by incorrect resource usage by customers is not covered by the SLA.

Limits

  • Only VVR 11.8 and later engines are supported. The OSS Connector and Postgres CDC Connector support accessing cloud resources with RAM roles.

  • Up to 10 RAM roles can be referenced per workspace.

  • A single add operation supports selecting up to 5 roles.

  • Only regular service roles (SR) can be referenced. Service-linked roles (SLR) are not supported.

  • STS tokens are not supported for local debugging of PyFlink and Flink JAR jobs. The jobs must be deployed to a cluster before use.

  • Only RAM identity authentication for Alibaba Cloud services is supported.

Permission preparation

Step 1: Create and configure a RAM role

This role is the identity credential that the Flink service uses to access other cloud resources. Flink assumes this role to obtain temporary credentials and access cloud resources as the role.

1. Create a RAM role

  1. Log on to the RAM console - Roles page and click Create Role. Keep the default options (the trusted entity is the current Alibaba Cloud account) and click OK.

  2. Enter a recognizable role name, for example, FlinkRoleForOSSRead, and click OK.

2. Add a trust policy

Flink assumes the RAM role to obtain temporary credentials. The RAM role must trust Flink to assume it.

After the role is created, on the role details page, click the Trust Policy tab and click Edit Trust Policy. Add "Service": ["stream.aliyuncs.com"] to Principal to trust Flink to assume the role. For more information, see Modify the trust policy of a RAM role.

{
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Effect": "Allow",
      "Principal": {
        "Service": [
          "stream.aliyuncs.com"
        ]
      }
    }
  ],
  "Version": "1"
}

3. Grant permissions to access cloud resources

Flink uses the RAM role identity to access cloud resources. Grant the required permissions to the RAM role in advance to prevent access errors.

On the role details page, click the Permissions tab and click Grant Permission to grant the role permissions to access target cloud resources.

For example, to access OSS, grant AliyunOSSReadOnlyAccess (read-only) or AliyunOSSFullAccess (full) permissions. For more information, see Grant permissions to a RAM role.

Step 2: Grant permissions to a RAM user

Create a permission policy and grant it to the RAM user. This allows the user to pass the RAM role created in Step 1 to the Flink service for assumption.

Note

If the RAM user in Step 3 is already associated with the AliyunRAMFullAccess or AliyunStreamFullAccess policy, the user already has the PassRole permission. You can skip this step.

Create a permission policy

Log on to the RAM console - Policies page and click Create Policy. Switch to Script mode and edit the policy content.

{
  "Version": "1",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ram:ListRoles"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": "ram:PassRole",
      "Resource": "acs:ram::<account-id>:role/<role-name>",
      "Condition": {
        "StringEquals": {
          "acs:Service": "stream.aliyuncs.com"
        }
      }
    }
  ]
}

Permission

Description

ram:ListRoles

Allows the user to view the role list under the account, so that the role can be selected in the Flink console.

ram:PassRole

Allows the user to pass the specified role to the Flink cloud service. Replace <account-id> and <role-name> in the policy with actual values:

  • <account-id>: The UID of the Alibaba Cloud account.

  • <role-name>: The name of the RAM role created in Step 1.

Add a Condition to restrict passing the role to stream.aliyuncs.com only.

Click OK to save the policy, for example, as FlinkPassRolePolicy. For more information, see Create a custom policy.

Grant permissions to the RAM user

  1. Log on to the RAM console - Users page. Find the RAM user to authorize and click Add Permissions in the Actions column.

  2. In the Add Permissions panel, search for and select the policy created in Step 2 (for example, FlinkPassRolePolicy), then click Confirm. For more information, see Grant permissions to a RAM user.

Step 3: Reference the RAM role in Flink

Users authorized in Step 2 can pass the RAM role from Step 1 to Flink. Flink assumes the role to obtain temporary credentials and access cloud resources as the role.

Add a RAM role reference

  1. Log on to the Realtime Compute console and enter the target workspace.

  2. In the left-side navigation pane, choose Security Services > Access Security.

  3. Click the RAM Roles tab.

  4. Click Reference RAM Role.

  5. In the dialog box, configure the following:

    Item

    Required

    Description

    RAM role

    Yes

    Select the role from the drop-down list. Fuzzy search by role name and multi-select (up to 5 per operation) are supported. Referenced roles cannot be selected again.

    Note
    • The role list contains regular service roles under the Alibaba Cloud account that owns the current namespace.

    • The operator must belong to the same Alibaba Cloud account as the current namespace and have the ListRoles permission to view the roles.

    Description

    No

    Role description. Up to 256 characters.

  6. Click Test. The system automatically checks the following two items:

    • PassRole permission check: The current user has the ram:PassRole permission on the selected RAM role.

    • Trust policy check: The selected RAM role trusts the current Flink namespace to assume it.

  7. After the checks pass, click OK.

Use the RAM role in jobs

After the RAM role is referenced, specify the role name using the akless.assume-role.role-name parameter in the job code. Flink assumes the role to obtain the temporary STS token and accesses cloud resources as the role.

Note

Only the OSS Connector and Postgres CDC Connector of VVR 11.8 and later engines support this feature.

Parameter description

Parameter

Type

Required

Description

akless.assume-role.role-name

String

No

The name of the RAM role, for example, oss-read. The role must be referenced in advance under Access Security > RAM Roles. Otherwise, the job submission fails.

Priority rules

  • If an AccessKey pair (accessKeyId + accessKeySecret) is explicitly specified, the AccessKey pair takes the highest priority.

  • If no AccessKey pair is specified but akless.assume-role.role-name is, the STS token of the role is used.

  • Different connectors in a job can use different roles by specifying different akless.assume-role.role-name values.

OSS example

Add the following configuration in Other Configuration under Runtime Parameters on the Deployment Details tab:

# OSS
fs.oss.bucket.<bucketName>.akless.assume-role.role-name: <your-role-name>
fs.oss.inner.bucket: <workspace-associated-bucket-name>

# OSS-HDFS
fs.oss.jindo.akless.assume-role.role-name: <your-role-name>

Parameter

Description

<bucketName>

The bucket name in the target file system path parameter (path).

<workspace-associated-bucket-name>

Check the Storage Type field on the workspace list page to determine whether the workspace uses a self-managed OSS bucket or fully managed storage, and obtain the bucket name accordingly:

  • OSS bucket: In the workspace details dialog box, find the OSS Bucket field, which is the OSS bucket name associated with the current workspace.

  • Fully managed: flink-fullymanaged-<workspace-id>, for example, flink-fullymanaged-db12345678. The workspace ID is available in the details dialog box.

<your-role-name>

The name of the RAM role used to access OSS.

Manage RAM role references

Note

Editing or removing a RAM role in Flink affects only the Flink reference to the RAM role. It does not directly modify the RAM role.

Edit a RAM role

  1. Under Security Services > Access Security > RAM Roles, find the target role and click Edit in the Actions column.

  2. In the dialog box, modify the description. The role name cannot be modified.

  3. Click Test. After the checks pass, click OK.

Remove a RAM role

Important

After you remove a RAM role, all jobs in the current namespace that reference the role will fail. Proceed with caution.

  1. Under Security Services > Access Security > RAM Roles, find the target role and click Remove in the Actions column.

  2. In the confirmation dialog box, enter the role name and click Confirm Removal.

Refresh role status

Click Refresh in the upper-right corner of the RAM Roles list to check the status of all referenced roles in bulk.

Status

Description

Normal

The role exists in RAM and the STS token is valid.

Abnormal

The role has been deleted from RAM, or the trust policy no longer allows Flink to assume it. Jobs referencing this role may run abnormally.

Appendix: STS invocation flow

Alibaba Cloud RAM provides two core role-related authorization models: direct assumption (AssumeRole) and delegated authorization (PassRole).

Model 1: Direct assumption (sts:AssumeRole)

  • Core action: A trusted entity (such as a RAM user or an application) actively calls the STS AssumeRole API to obtain temporary credentials for a RAM role, effectively "transforming" into that role.

  • Authorization chain: Entity ACalls sts:AssumeRoleAssumes Role RObtains Role R permissions.

  • Permission requirement: Entity A must be granted the sts:AssumeRole permission.

  • Typical scenario: An application running on ECS or a local server needs to temporarily access OSS. The application uses its own AccessKey pair to call AssumeRole, obtains temporary credentials, and then uses them to access OSS. In this scenario, Entity A is the active executor.

Model 2: Delegated authorization (ram:PassRole)

  • Core action: An entity (such as a RAM user) "passes" a RAM role to a cloud service (such as Flink), authorizing the service to assume the role. The user does not assume the role.

  • Authorization chain: User_B → Passes Role_A → To the cloud service → The cloud service calls sts:AssumeRole to assume Role_A → The cloud service obtains Role_A permissions.

  • Permission requirement: User B must be granted the ram:PassRole permission, and Role A must trust the cloud service to assume it.

  • Typical scenario: A developer (User_B) develops a job in the Flink console and specifies a role (Role_A). To allow the Flink service to access cloud resources on behalf of the user, the user must have the permission to pass Role_A to the Flink service. In this scenario, the user is the authorizer, and the cloud service is the executor.