All Products
Search
Document Center

Key Management Service:How Key Management Service works with RAM

Last Updated:Mar 31, 2026

Resource Access Management (RAM) is the access control service for Alibaba Cloud. Use RAM to manage which identities — RAM users, RAM roles, or applications — can access Key Management Service (KMS) resources and what operations they can perform.

By default, no RAM identity has any permissions to KMS resources. All access must be explicitly granted through policies attached to RAM identities.

KMS supports the following RAM features:

RAM featureSupported
RAM user-based accessSupported
Security Token Service (STS) token-based accessSupported
Identity-based policies (account level)Supported
Identity-based policies (resource group level)Supported
Operation-level authorizationSupported
Resource-level authorizationSupported
Condition keys specific to Alibaba Cloud servicesSupported
Tag-based authenticationSupported
Regular service roleSupported
Service-linked roleSupported
For the full list of Alibaba Cloud services that work with RAM or STS, see Services that work with RAM and Services that work with STS.

RAM user-based access

A RAM user is a physical identity with a fixed ID and credentials. It represents a person or an application.

KMS verifies a RAM user's permissions before allowing access to resources. RAM users have no permissions by default — the administrator account must attach policies to grant access.

Credential types:

  • Console access: username and password

  • API access: AccessKey pair

An administrator account is an Alibaba Cloud account, or a RAM user or a RAM role with administrative rights.

Security best practices:

  • Rotate RAM user passwords regularly.

  • Never embed a plaintext AccessKey pair in code.

  • Where possible, use STS tokens instead of long-term AccessKey pairs to reduce credential exposure.

For more information, see Identity management.

For information about policies you can attach to RAM users, see System policies for KMS and Custom policies for KMS.

References:

STS token-based access

An STS token is a temporary identity credential issued by Security Token Service (STS). RAM roles use STS tokens to access cloud resources.

A RAM role is a virtual RAM identity with no long-term credentials — it must be assumed by a trusted entity, which then receives a temporary STS token. Because STS tokens are short-lived, they reduce credential exposure and lower the risk to your cloud assets compared to long-term AccessKey pairs.

RAM roles have no permissions by default. Attach the required policies using the administrator account before a role can access KMS resources. See System policies for KMS and Custom policies for KMS for available policies.

For trusted entity types and typical scenarios, see RAM role overview.

References:

Identity-based policies

KMS supports identity-based policies. Attach these policies to RAM users, RAM user groups, or RAM roles to define which operations those identities can perform on which resources and under what conditions.

By management type:

TypeCreated byCan be modified
System policyAlibaba CloudNo — read-only
Custom policyYouYes — create in the RAM console or via API

By authorization scope:

TypeScopePrecedence
Account-level policyAll resources within an Alibaba Cloud accountHigher
Resource group-level policyAll resources within a resource groupLower

Account-level policies take precedence over resource group-level policies. Specify the authorization scope when granting permissions to a RAM identity. For details, see Policy models.

References:

Operation-level authorization

KMS supports operation-level authorization. In a policy, the Action element specifies which operations an identity can or cannot perform.

The Action element uses the format <ram-code>:<action-name>. The RAM code for KMS is kms.

Example: The following policy grants permission to list and describe KMS resources, but no other operations.

"Action": [
  "kms:List*",
  "kms:Describe*"
]

For all KMS operations that support operation-level authorization, see Custom policies for KMS.

Resource-level authorization

KMS supports resource-level authorization. In a policy, the Resource element specifies which resource objects an identity can or cannot operate on.

Resources are identified by Alibaba Cloud Resource Names (ARN) in the format acs:<ram-code>:<region>:<account-id>:<relative-id>. If an operation does not support resource-level authorization, use a wildcard (*) to apply it to all resources.

Example: The following policy applies to all KMS keys and their sub-resources within the specified account and region.

"Resource": [
  "acs:kms:${region}:${account}:key",
  "acs:kms:${region}:${account}:key/*"
]

For all KMS resources that support resource-level authorization, see Custom policies for KMS.

Condition keys specific to Alibaba Cloud services

KMS supports condition keys specific to Alibaba Cloud services. In a policy, the Condition element specifies conditions that must be met for the policy to take effect.

Each condition consists of a conditional operator, a condition key, and a condition value. Condition keys use one of two formats:

  • Common condition keys: acs:<condition-key>

  • Service-specific condition keys: <ram-code>:<condition-key>

For common condition keys, see Policy elements.

Example: The following condition restricts a policy to KMS resources tagged with Project: Apollo.

"Condition": {
  "StringEqualsIgnoreCase": {
    "kms:tag/Project": [
      "Apollo"
    ]
  }
}

For KMS-specific condition keys, see Custom policies for KMS.

Tag-based authentication

KMS supports tag-based authentication. Attach tags to KMS resources, then use condition keys in policies to restrict access based on those tags. See the Condition element example in the Condition keys specific to Alibaba Cloud services section for a typical pattern.

Regular service roles

A regular service role is a RAM role assumed by a trusted Alibaba Cloud service to access other cloud services on your behalf.

When you use certain KMS features, KMS automatically triggers user authorization to create a regular service role and attach the required permissions. After creation, KMS assumes this role to interact with other cloud services.

You can also manually create, modify, or delete regular service roles in RAM, and update their attached policies.

Important

Modifying a regular service role or its policies may affect KMS features that depend on that role. Proceed with caution.

For details, see Regular service roles.

Service-linked roles

A service-linked role is a RAM role that only KMS can assume. It is used to access other Alibaba Cloud services on behalf of KMS.

When you use certain KMS features, KMS automatically triggers user authorization to create the service-linked role and attach the required permissions.

Unlike regular service roles, service-linked roles have the following restrictions:

  • Policies are defined, updated, and managed by KMS.

  • You can view the attached policies in RAM, but cannot modify or delete them.

  • You cannot attach additional policies to, or detach policies from, service-linked roles.

For details, see Service-linked roles.

References