Introduction to RAM and STS
Resource Access Management (RAM) and Security Token Service (STS) are permission management systems from Alibaba Cloud.
The primary purpose of RAM is to control permissions for your Alibaba Cloud account. You can use RAM to create and manage RAM users and grant them different permissions to control their access to your resources.
STS is a security token management system that provides temporary access credentials. You can use STS to grant temporary access to users.
RAM and STS solve a core problem: how to securely grant access to other users without exposing the AccessKey of your Alibaba Cloud account. If your Alibaba Cloud account's AccessKey is exposed, it creates a major security risk. Anyone who obtains the AccessKey can access and manage all resources under your account and may steal sensitive data.
RAM provides a long-term access control mechanism. You can create RAM users and grant them specific permissions to provide different levels of access. The AccessKeys of RAM users must also be kept confidential. However, if a RAM user's AccessKey is exposed, it does not compromise your entire account. RAM users are typically created for long-term use.
In contrast to the long-term control provided by RAM, STS provides temporary access authorization. You can call STS to obtain a temporary AccessKey and a security token. You can then send the temporary AccessKey and token to users for temporary access to specific resources. Permissions obtained from STS are strictly limited and time-bound. Therefore, if these credentials are exposed, the security impact is minimal.
Terms
The following terms are fundamental to understanding RAM and STS:
- RAM user: A user created in the RAM console. You can generate an independent AccessKey for a RAM user during or after creation. After creation, you can configure a logon password and assign permissions to the RAM user. A RAM user can perform authorized operations. You can think of a RAM user as an entity that has specific permissions and can initiate operations.
- Role: A virtual user that represents a collection of permissions. A role does not have an independent logon password or AccessKey. A RAM user can assume a role. When a RAM user assumes a role, the RAM user obtains the permissions of that role.
- Authorization policy (Policy): A set of rules that defines permissions. For example, a policy can allow a RAM user to read or write specific resources.
- Resource: A cloud resource that a RAM user can access, such as all instances in Tablestore, a specific instance, or a table within an instance.
The relationship between a RAM user and a role is similar to the relationship between a person and their identities. For example, a person can be an employee at work and a father at home. The same person plays different roles in different scenarios. When playing different roles, the person has the permissions associated with that role. A role itself is not an operational entity. It becomes a complete operational entity only after a user assumes the role. Additionally, multiple users can assume the same role at the same time.
Usage example
To avoid the security risk of an exposed AccessKey, an Alibaba Cloud account administrator uses RAM to create two RAM users, named A and B. The administrator generates independent AccessKeys for A and B, grants read permissions to User A, and grants write permissions to User B. The administrator can revoke the permissions of the RAM users in the RAM console at any time.
Now, assume you need to grant temporary access to the Alibaba Cloud Link WAN APIs to another user. In this case, you should not expose User A's AccessKey. Instead, you can create a new role, named C, and grant it read permission for the Alibaba Cloud Link WAN APIs. Note that Role C cannot be used directly because it does not have an AccessKey. Role C is only a virtual entity that has permission to access the Alibaba Cloud Link WAN APIs.
You can call the STS AssumeRole API operation to obtain temporary authorization to access the Alibaba Cloud Link WAN APIs. In the API request, the value of the RoleArn parameter must be the ARN of Role C. If the call is successful, STS returns a temporary AccessKey ID, AccessKey secret, and security token as access credentials. The validity period of the credentials is specified in the AssumeRole request. You can send these credentials to the user who needs access. The user can then use these credentials to obtain temporary permission to access the Alibaba Cloud Link WAN APIs.
Why are RAM and STS complex to use?
The concepts and usage of RAM and STS can be complex. This complexity is a trade-off that provides enhanced account security and flexible permission control at the expense of ease of use.
Separating RAM users from roles is done to separate the entity that performs operations from the virtual entity that represents a collection of permissions. If a user needs multiple permissions, such as read and write permissions, but each operation only requires a subset of those permissions, you can create two roles. One role has read permissions, and the other has write permissions. Then, you can create a RAM user that can assume both roles. When the user needs read permissions, they can assume the role with read permissions. The same applies when they need write permissions. This approach reduces the risk of excessive permission exposure during each operation. Moreover, using roles, you can grant permissions to other users, which facilitates collaboration.
STS provides more flexible permission control. For example, you can set the validity period as needed. However, if you need a long-term access credential, you can use the RAM user management feature instead of STS.
For more information about RAM and STS, see the Resource Access Management documentation.