All Products
Search
Document Center

ApsaraMQ for Kafka:Service-linked roles for ApsaraMQ for Kafka

Last Updated:Mar 11, 2026

ApsaraMQ for Kafka uses service-linked roles to access other Alibaba Cloud services, such as Elastic Compute Service (ECS), Function Compute, and Key Management Service (KMS). A service-linked role is a Resource Access Management (RAM) role that the system creates automatically the first time you use the associated feature. No manual setup is required.

For more information about how service-linked roles work, see Service-linked roles.

Roles

ApsaraMQ for Kafka uses four service-linked roles:

RolePurposeAuto-created when you...
AliyunServiceRoleForAlikafkaManage ECS network interfaces and security groups, and query VPC resources for Kafka instances.Activate ApsaraMQ for Kafka in the console for the first time.
AliyunServiceRoleForAlikafkaConnectorAccess downstream services -- Function Compute, OSS, Elasticsearch, DataWorks, EventBridge, Tablestore, ApsaraDB RDS, AnalyticDB for PostgreSQL, and AnalyticDB for MySQL -- for the connector feature.Create a connector in the console for the first time.
AliyunServiceRoleForAlikafkaInstanceEncryptionAccess KMS to encrypt Kafka instance disks. Currently available only through API.Deploy an instance with disk encryption by calling the StartInstance operation for the first time.
AliyunServiceRoleForAlikafkaETLAccess Function Compute to run ETL tasks for data analysis.Enable ETL in the console for the first time. See Manage ETL tasks.

Permissions

Each role has a system-managed policy that grants only the permissions its feature requires. The following sections summarize each policy. Expand the JSON blocks for full policy documents.

AliyunServiceRoleForAlikafka

Manages ECS network interfaces and security groups, and queries VPC resources to set up network connectivity for Kafka instances.

Permitted actions:

  • ECS -- Create, describe, and delete network interfaces, network interface permissions, and security groups. Authorize and revoke security group rules.

  • VPC -- Describe vSwitches and VPCs.

  • RAM -- Delete the service-linked role itself (scoped to alikafka.aliyuncs.com).

Full JSON policy

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:CreateNetworkInterface",
                "ecs:DeleteNetworkInterface",
                "ecs:DescribeNetworkInterfaces",
                "ecs:CreateNetworkInterfacePermission",
                "ecs:DescribeNetworkInterfacePermissions",
                "ecs:DeleteNetworkInterfacePermission",
                "ecs:CreateSecurityGroup",
                "ecs:AuthorizeSecurityGroup",
                "ecs:DescribeSecurityGroupAttribute",
                "ecs:RevokeSecurityGroup",
                "ecs:DeleteSecurityGroup",
                "ecs:DescribeSecurityGroups"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "vpc:DescribeVSwitches",
                "vpc:DescribeVpcs"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Effect": "Allow",
            "Action": "ram:DeleteServiceLinkedRole",
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "ram:ServiceName": "alikafka.aliyuncs.com"
                }
            }
        }
    ]
}

AliyunServiceRoleForAlikafkaConnector

Interacts with the downstream services that connectors support, including Function Compute, databases, object storage, and event streaming.

Permitted actions:

  • Function Compute -- Invoke, create, delete, and list functions, services, service versions, aliases, and layers.

  • ApsaraDB RDS -- Describe databases.

  • OSS -- List buckets and get bucket ACLs.

  • Elasticsearch -- Describe and list instances.

  • DataWorks -- Create and query real-time processes.

  • EventBridge -- Create, update, get, delete, list, start, pause, and list metrics for event streamings.

  • Tablestore -- Full table and row operations, including search indexes and service management.

  • AnalyticDB for PostgreSQL -- Describe instances and instance attributes.

  • AnalyticDB for MySQL -- Describe clusters, schemas, and tables.

  • RAM -- Delete the service-linked role itself (scoped to connector.alikafka.aliyuncs.com).

Full JSON policy

{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "fc:InvokeFunction",
                "fc:GetFunction",
                "fc:ListServices",
                "fc:ListFunctions",
                "fc:ListServiceVersions",
                "fc:ListAliases",
                "fc:CreateService",
                "fc:DeleteService",
                "fc:CreateFunction",
                "fc:DeleteFunction",
                "fc:CreateLayerVersion",
                "fc:ListLayers"
            ],
            "Resource": "*"
        },
        {
            "Action": [
                "rds:DescribeDatabases"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oss:ListBuckets",
                "oss:GetBucketAcl"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "elasticsearch:DescribeInstance",
                "elasticsearch:ListInstance"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "dataworks:CreateRealTimeProcess",
                "dataworks:QueryRealTimeProcessStatus"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "eventbridge:CreateEventStreaming",
                "eventbridge:UpdateEventStreaming",
                "eventbridge:GetEventStreaming",
                "eventbridge:DeleteEventStreaming",
                "eventbridge:ListEventStreamings",
                "eventbridge:StartEventStreaming",
                "eventbridge:PauseEventStreaming",
                "eventbridge:ListEventStreamingMetrics"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ots:GetInstance",
                "ots:ListInstance",
                "ots:ListTable",
                "ots:CreateTable",
                "ots:UpdateTable",
                "ots:DescribeTable",
                "ots:GetRow",
                "ots:PutRow",
                "ots:UpdateRow",
                "ots:DeleteRow",
                "ots:GetRange",
                "ots:BatchGetRow",
                "ots:BatchWriteRow",
                "ots:BulkImport",
                "ots:Search",
                "ots:OpenOtsService",
                "ots:GetOtsServiceStatus",
                "ots:InsertInstance",
                "ots:DeleteTable",
                "ots:CreateSearchIndex",
                "ots:DeleteSearchIndex",
                "ots:UpdateSearchIndex"
            ],
            "Effect": "Allow",
            "Resource": "*"
        },
        {
            "Action": [
                "gpdb:DescribeDBInstances",
                "gpdb:DescribeDBInstanceAttribute"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "adb:DescribeDBClusters",
                "adb:DescribeSchemas",
                "adb:DescribeTables"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Effect": "Allow",
            "Action": "ram:DeleteServiceLinkedRole",
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "ram:ServiceName": "connector.alikafka.aliyuncs.com"
                }
            }
        }
    ]
}

AliyunServiceRoleForAlikafkaInstanceEncryption

Manages KMS keys for disk encryption. Encrypt, decrypt, and data key generation operations are restricted to keys tagged with acs:alikafka:instance-encryption=true.

Permitted actions:

  • KMS -- List keys, list aliases, list resource tags, describe keys, tag and untag resources.

  • KMS (conditional) -- Encrypt, decrypt, and generate data keys only when the key is tagged with acs:alikafka:instance-encryption=true.

  • RAM -- Delete the service-linked role itself (scoped to instanceencryption.alikafka.aliyuncs.com).

Full JSON policy

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "kms:Listkeys",
                "kms:Listaliases",
                "kms:ListResourceTags",
                "kms:DescribeKey",
                "kms:TagResource",
                "kms:UntagResource"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "kms:Encrypt",
                "kms:Decrypt",
                "kms:GenerateDataKey"
            ],
            "Resource": "*",
            "Effect": "Allow",
            "Condition": {
                "StringEqualsIgnoreCase": {
                    "kms:tag/acs:alikafka:instance-encryption": "true"
                }
            }
        },
        {
            "Action": "ram:DeleteServiceLinkedRole",
            "Resource": "*",
            "Effect": "Allow",
            "Condition": {
                "StringEquals": {
                    "ram:ServiceName": "instanceencryption.alikafka.aliyuncs.com"
                }
            }
        }
    ]
}

AliyunServiceRoleForAlikafkaETL

Manages Function Compute resources for ETL task execution and passes the default Function Compute role.

Permitted actions:

  • Function Compute -- Invoke, create, delete, and list functions, services, service versions, and aliases.

  • RAM -- Delete the service-linked role itself (scoped to etl.alikafka.aliyuncs.com).

  • RAM -- Pass the aliyunfcdefaultrole role to Function Compute.

Full JSON policy

{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "fc:InvokeFunction",
                "fc:GetFunction",
                "fc:ListServices",
                "fc:ListFunctions",
                "fc:ListServiceVersions",
                "fc:ListAliases",
                "fc:CreateService",
                "fc:DeleteService",
                "fc:CreateFunction",
                "fc:DeleteFunction"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "ram:DeleteServiceLinkedRole",
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "ram:ServiceName": "etl.alikafka.aliyuncs.com"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": "ram:PassRole",
            "Resource": "acs:ram:*:*:role/aliyunfcdefaultrole",
            "Condition": {
                "StringEquals": {
                    "acs:Service": "fc.aliyuncs.com"
                }
            }
        }
    ]
}

Deletion

Warning

Deleting a service-linked role removes the permissions that ApsaraMQ for Kafka relies on for the associated feature. That feature stops working until you recreate the role. Exercise caution when you delete a service-linked role.

To recreate a deleted role, see Create a RAM role for a trusted Alibaba Cloud service and Grant permissions to a RAM role.

FAQ

A service-linked role is not created for my RAM user

If the role already exists under your Alibaba Cloud account, your RAM user inherits it automatically. If inheritance fails, create a custom policy that grants ram:CreateServiceLinkedRole for the relevant service and attach it to your RAM user.

Replace <service-name> with the value for the role you need:

RoleService name value
AliyunServiceRoleForAlikafkaalikafka.aliyuncs.com
AliyunServiceRoleForAlikafkaConnectorconnector.alikafka.aliyuncs.com
AliyunServiceRoleForAlikafkaInstanceEncryptioninstanceencryption.alikafka.aliyuncs.com
AliyunServiceRoleForAlikafkaETLetl.alikafka.aliyuncs.com

Policy template:

{
    "Statement": [
        {
            "Action": [
                "ram:CreateServiceLinkedRole"
            ],
            "Resource": "*",
            "Effect": "Allow",
            "Condition": {
                "StringEquals": {
                    "ram:ServiceName": "<service-name>"
                }
            }
        }
    ],
    "Version": "1"
}

To apply this policy:

  1. Log on to the RAM console.

  2. Create a custom policy with the JSON above.

  3. Attach the policy to your RAM user.

If the role is still not created after you attach the policy, attach the AliyunKafkaFullAccess system policy to your RAM user. For more information, see Grant permissions to the RAM user.