All Products
Search
Document Center

ApsaraMQ for RocketMQ:Custom policies for ApsaraMQ for RocketMQ

Last Updated:Jul 09, 2026

Resource Access Management (RAM) policies control who can access your ApsaraMQ for RocketMQ resources and what actions they can perform. If the built-in system policies are too broad for your needs, create custom policies to enforce least-privilege access.

When to use custom policies

System policies grant predefined sets of permissions. Use a custom policy when you need to:

  • Restrict access to a specific instance, topic, or consumer group

  • Allow only certain actions, such as creating instances or deleting topics

  • Combine multiple permission scopes in a single policy

How custom policies work

After you create a custom policy, attach it to a RAM user, RAM user group, or RAM role to grant the specified permissions.

Keep these rules in mind:

  • Detach before deleting. You can delete a policy that is not attached to a principal. If the policy is attached to a principal, detach it first.

  • Use version control. Custom policies support versioning. You can manage custom policy versions based on the version management mechanism provided by RAM.

Resource ARN format

Each Resource field in a policy uses an Alibaba Cloud Resource Name (ARN) to identify the target. The ARN format for ApsaraMQ for RocketMQ is:

acs:rocketmq:{regionId}:{accountId}:instance/{InstanceId}/topic/{TopicName}
SegmentDescription
{regionId}Region where the instance resides. See Endpoints.
{accountId}Your Alibaba Cloud account ID.
{InstanceId}ApsaraMQ for RocketMQ instance ID.
{TopicName}Topic name.
{ConsumerGroupId}Consumer group ID.

Use wildcards to broaden the scope:

PatternScope
instance/*All instances under the account in the specified region
instance/{InstanceId}*A specific instance and all its child resources (topics, consumer groups)
*:{#accountId}:*/*All resources under the account across all regions

Policy examples

Important

Replace the placeholder values in the following examples with your actual resource identifiers before applying the policy.

Grant full access to a specific instance

This policy grants all ApsaraMQ for RocketMQ permissions on a single instance and its child resources. It includes three statements because different resource scopes are required for listing instances, operating on a specific instance, and querying diagnostics.

{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "rocketmq:ListInstances"
            ],
            "Resource": [
                "acs:rocketmq:{regionId}:{accountId}:instance/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "rocketmq:*"
            ],
            "Resource": [
                "acs:rocketmq:{regionId}:{accountId}:instance/{InstanceId}*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "rocketmq:ListAnalyticsQuery"
            ],
            "Resource": [
                "acs:rocketmq:*:{#accountId}:*/*"
            ]
        }
    ]
}

The three statements serve different purposes:

  1. List instances -- rocketmq:ListInstances on all instances (instance/*) lets the user browse and locate the target instance in the console.

  2. Full instance access -- rocketmq:* on the specific instance (instance/{InstanceId}*). The trailing wildcard covers all child resources.

  3. Diagnostics access -- rocketmq:ListAnalyticsQuery enables diagnostics queries. The wildcard region (*) allows cross-region queries.

Grant permission to create instances

This policy allows a RAM user to create ApsaraMQ for RocketMQ instances in a specific region. The resource uses instance/* because the instance ID is not yet known at creation time.

{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "rocketmq:CreateInstance"
            ],
            "Resource": [
                "acs:rocketmq:{regionId}:{accountId}:instance/*"
            ]
        }
    ]
}

Grant permission to delete a specific topic

This policy restricts the DeleteTopic action to a single topic on a specific instance. Use this pattern to delegate topic cleanup without granting broader permissions.

{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "rocketmq:DeleteTopic"
            ],
            "Resource": [
                "acs:rocketmq:{regionId}:{accountId}:instance/{InstanceId}/topic/{TopicName}"
            ]
        }
    ]
}

Grant full access to instance diagnostics

This policy grants all diagnostics-related permissions: submitting, listing, and retrieving analytics queries. The wildcard region and resource pattern enable diagnostics access across all instances and regions under the account.

{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "rocketmq:GetAnalyticsQuery",
                "rocketmq:SubmitAnalyticsQuery",
                "rocketmq:ListAnalyticsQuery"
            ],
            "Resource": [
                "acs:rocketmq:*:{#accountId}:*/*"
            ]
        }
    ]
}

Grant a RAM user permissions to view the instance list and operate a specified instance

{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "rocketmq:ListInstances",
                "rocketmq:GetUserTags"
            ],
            "Resource": [
                "acs:rocketmq:*:*:instance/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "rocketmq:*"
            ],
            "Resource": [
                "acs:rocketmq:{regionId}:{accountId}:instance/{InstanceId}*"
            ]
        }
    ]
}
Note

This example illustrates the difference in Resource configuration between list-type actions and instance-specific actions:

  • List-type actions (for example, rocketmq:ListInstances and rocketmq:GetUserTags): The Resource field must use the wildcard format acs:rocketmq:*:*:instance/*. You cannot restrict the Resource to a specific instance ARN for list-type actions. If you do, the action fails.

  • Instance read/write actions (for example, rocketmq:*): You can restrict the Resource to a specific instance ARN, such as acs:rocketmq:{regionId}:{accountId}:instance/{InstanceId}*.

If you grant a RAM user permissions only for a specific instance without including list-type action permissions, the RAM user receives a NoPermission error or cannot display the instance list in the console or when calling APIs.

What's next

FAQ

Q: Why do I receive a "valid resource owner failed" or "AccessDenied (OwnerId forbidden)" error when accessing ApsaraMQ for RocketMQ over HTTP?

Cause: This error typically occurs due to one of the following reasons:

  • Signature construction error: The HTTP request signature does not comply with the HMAC-SHA256 V4 specification. Common issues include an incorrectly constructed Canonical String or a malformed Authorization header.

  • Resource mismatch in RAM policy: The Resource field in your RAM policy does not exactly match the target topic or instance. Topic names in ApsaraMQ for RocketMQ are case-sensitive. The correct Resource format for HTTP protocol message publishing is acs:mq:*:*:instance/{InstanceId}/topic/{TopicName}.

  • Insufficient permissions: The AccessKey pair or STS credentials used for the request do not have the required permissions, such as mq:PUB for publishing messages.

Resolution:

  1. Verify that your HTTP request signature strictly follows the HMAC-SHA256 V4 specification, including the correct format for the Canonical String, signed headers, and the Authorization header.

  2. Check that the Resource field in your RAM policy matches the actual topic and instance names exactly. Pay close attention to case sensitivity.

  3. Confirm that the AccessKey pair or STS credentials have the necessary permissions for the operation you are performing (for example, mq:PUB for publishing messages).

Recommendation: To avoid HTTP authentication complexity and potential signature errors, use the official RocketMQ SDK, which handles request signing automatically.

Q: Can I use a RequestId to query the specific reason why an ApsaraMQ for RocketMQ permission verification failed?

No. Currently, Alibaba Cloud does not support querying granular IAM (Identity and Access Management) authentication decision details by using a RequestId. When a permission verification fails, the backend returns only a generic AccessDenied error without exposing specific policy evaluation details, such as which policy denied the request or which condition was not met.

To troubleshoot permission verification failures, use the following self-service approaches:

  • Check your permission policies: Review the RAM user or role's attached policies and verify that all required actions are explicitly allowed.

  • Verify Resource ARN matching: Confirm that the Resource field in your policies matches the actual resource ARNs, including the correct region ID, account ID, instance ID, and topic or consumer group name.

  • Check your signature logic: If you are using the HTTP protocol to access ApsaraMQ for RocketMQ, verify that your request signing logic is correct.

  • Review permission boundaries and trust policies: If the RAM user or role is subject to a permission boundary or trust policy, verify that these configurations are not restricting the required actions.

Q: How do I grant a RAM user the Cloud Monitor permissions required to configure ApsaraMQ for RocketMQ alerts?

ApsaraMQ for RocketMQ custom permission policies control access to ApsaraMQ for RocketMQ resources only and do not include Cloud Monitor permissions. To allow a RAM user to configure ApsaraMQ for RocketMQ alerts in Cloud Monitor, you must grant Cloud Monitor permissions to the RAM user separately.

To grant the required Cloud Monitor read-only permissions:

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

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

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

  4. In the Add Permissions panel, configure the following settings:

    • Set Authorization Scope based on your requirements.

    • Set Policy Type to System Policy.

  5. In the search box, enter AliyunCloudMonitorReadOnlyAccess and select the policy from the search results.

  6. Click OK to save the permission grant.

After the permission is granted, the RAM user can view Cloud Monitor metrics and configure alert rules for ApsaraMQ for RocketMQ instances.

Q: Should I use RAM custom policies or ACL to control message sending permissions in an ApsaraMQ for RocketMQ 5.0 development environment?

To control message send and receive permissions in a development or testing environment, use ACL (Access Control List) rather than RAM custom policies.

  • ACL: Designed for application-level message send and receive permission control. ACL lets you grant specific users or applications permissions to publish to or subscribe from specific topics within an instance. This makes ACL well-suited for development and testing scenarios where you need to simulate message flows or control which applications can interact with specific topics.

  • RAM custom policies: Designed for Alibaba Cloud account-level resource management. RAM policies control operations on cloud resources, such as creating, modifying, or deleting ApsaraMQ for RocketMQ instances, topics, and consumer groups. RAM policies govern who can manage ApsaraMQ for RocketMQ resources, not who can send or receive messages through those resources.

In summary:

Scenario

Recommended method

Control which applications can send or receive messages within an instance

ACL

Control who can create, modify, or delete ApsaraMQ for RocketMQ resources (instances, topics, consumer groups)

RAM custom policies