Redis/Tair secrets

Updated at:

To access a Redis or Tair database, store the account password as a secret in Key Management Service (KMS). Applications then dynamically retrieve these credentials using an SDK, eliminating hardcoded sensitive information. Automatic rotation is also supported to reduce the risk of password compromise. This topic describes how to create, manage, and use Redis/Tair secrets.

How it works

Using Redis/Tair secrets eliminates the need to hardcode static database credentials in applications. An administrator creates a Redis/Tair secret in KMS. The application then calls the GetSecretValue API operation to retrieve the database username and password to access the Redis or Tair database.

KMS can only manage passwords for newly created Redis/Tair accounts, and only in dual-account mode. It cannot manage passwords for existing Redis or Tair accounts.

  • When configuring a Redis/Tair secret, define a base account name. KMS then calls the Redis or Tair API to create two new database accounts with the same permissions and password. For example, for Tair (Redis OSS-compatible), if the base account name is set to user, KMS creates two database accounts: user and user_clone.

  • The version stage label for the secret version corresponding to the user account is set to ACSCurrent, and the version stage label for the secret version corresponding to the user_clone account is set to ACSPrevious.

  • View these new accounts in the Redis console. Go to the Instances page, select the instance, and then click the Account Management tab.

This ensures that an application retrieving the secret value during rotation always receives a valid password. This dual-account mode improves application availability over a single-account approach.

Important
  • After a Redis/Tair account password is managed in KMS, do not modify or delete the password directly in Tair (Redis OSS-compatible). Otherwise, applications may fail.

  • KMS does not support managing passwords for Redis or Tair instances that use a cluster architecture. For more information about Tair (Redis OSS-compatible) architectures, see Product architecture.

The following diagram illustrates how to use a secret with Tair (Redis OSS-compatible).

image

Prerequisites

Create a Redis/Tair secret

You can configure automatic periodic rotation when creating a credential to reduce the security risk of credential leaks.

  1. Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose Resources > Secrets.

  2. Click the Database Secrets tab, select an Instance ID, and then click Create Secret.

  3. Select Create Single Secret or Create Bulk Secrets, configure the parameters, and then click OK.

    Note

    When creating a secret, the system automatically creates a Service-linked Role in ApsaraDB for Redis and attaches the AliyunServiceRolePolicyForKMSSecretsManagerForRedis permission policy to it. KMS assumes this role to manage Redis secrets and perform tasks such as password rotation.

    You can log on to the RAM console to view the details of service-linked roles and permission policies. For more information, see View a RAM role and View permission policy details.

    Parameter

    Description

    Database Type

    Select ApsaraDB for Redis/Tair Instance.

    Secret Name

    A custom credential name. Must be unique within the current region.

    ApsaraDB for Redis/Tair Instance

    Select a Redis instance or Tair instance under your Alibaba Cloud account.

    Account Management

    Only Manage Dual Accounts is supported.

    Secret Value

    Only new accounts are supported. Existing Redis/Tair accounts cannot be hosted.

    • Account Name: Specify a username prefix. KMS creates two database accounts with identical permissions by calling an API. For example, if you specify user, KMS creates user and user_clone.

    • Permissions: Set to Read/Write or Read-Only. Both new accounts have the same permissions.

    CMK

    Select the symmetric key used to encrypt the credential value. The key and the credential must belong to the same KMS instance.

    Important
    • The key and the credential must belong to the same KMS instance, and the key must be a symmetric key. For more information about the symmetric keys supported by KMS, see Key types and specifications.

    • If a RAM user or RAM role is used, it must have permissions to perform the GenerateDataKey operation using the encryption master key.

    Tag

    Add tags to the credential for classification. Each tag consists of a key-value pair.

    Note
    • Format of a tag key and a tag value: A tag key or a tag value can be up to 128 characters in length and can contain letters, digits, forward slashes (/), backslashes (\), underscores (_), hyphens (-), periods (.), plus signs (+), equal signs (=), colons (:), at signs (@), and spaces.

    • A tag key cannot start with aliyun or acs:.

    • Each credential supports up to 20 tag key-value pairs.

    Automatic Rotation

    Select whether to enable automatic rotation. When enabled, KMS periodically updates the credential value to reduce the risk of credential leaks.

    Rotation Period

    Set this parameter only when automatic rotation is enabled. Valid values: 6 hours to 365 days.

    Specifies the rotation interval. KMS periodically updates the credential value based on this setting.

    Description

    An optional description of the credential for identification and management.

    Advanced Settings > Policy Settings

    Set the access policy for the credential to control which RAM users or roles can read or modify it.

    You can select the default policy first and modify it later as needed.

Integrate applications with Redis/Tair secrets

KMS provides Alibaba Cloud SDKs, KMS Instance SDK, and a secret client to retrieve secret values. Applications can use these tools to integrate with Redis/Tair secrets. For more information about the SDKs, see SDK reference.

We recommend implementing a retry mechanism when using other SDKs to improve service stability.

Note

An Alibaba Cloud SDK is required for management operations such as creating Redis/Tair secrets or modifying their tags.

Rotate a Redis/Tair secret

When KMS rotates a Redis/Tair secret, it only resets the password of the associated account, not the account itself. Rotation is typically completed instantly. If a rotation task does not complete within two minutes, check the status of the Redis/Tair instance and the associated accounts.

Before rotation

  • During rotation, KMS requests the Redis or Tair service to reset the account password. Before rotating a secret, ensure that all applications retrieve the secret from KMS to avoid service disruptions.

  • Do not delete the associated Redis/Tair instance or accounts while a secret is being rotated. Otherwise, the rotation will fail.

  • An account check is recommended before rotation. Proceed with the rotation only after the check is successful. If the corresponding instance or accounts in Redis or Tair are deleted, KMS cannot rotate the secret.

How rotation works

When hosting Redis or Tair secrets in KMS, a dual-account alternating rotation mechanism is used. This mechanism maintains two database accounts with the same permissions and their corresponding KMS secret version stages (ACSCurrent and `ACSPrevious) to achieve seamless secret rotation. The specific process is as follows:

  1. Initial configuration

    • When you configure a custom account (for example, user) in KMS, KMS automatically calls the Redis/Tair API to create two database accounts: user and user_clone.

    • Initial state mapping:

      • The KMS secret version stage for the user account is ACSCurrent (the currently active version).

      • The KMS secret version stage for the user_clone account is ACSPrevious (the previous/standby version).

  2. First rotation

    • KMS calls the API to change the password of the standby account (user_clone).

    • Status switch: the current version is downgraded and the standby version is promoted:

      • The status of user changes from ACSCurrent to ACSPrevious.

      • The status of user_clone changes from ACSPrevious to ACSCurrent.

  3. Subsequent rotations: each time a rotation is triggered, KMS alternates changing the passwords of the two accounts and synchronizes their version stages in KMS to ensure continuously available access credentials.

    image

Configuring periodic automatic credential rotation effectively reduces the risk of leakage caused by long-term lack of updates. Additionally, the console supports immediate manual rotation, enabling rapid response to security incidents and timely mitigation of potential threats.

  1. Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose Resources > Secrets.

  2. Click the Database Secrets tab. Select an Instance ID. From the Type drop-down list, select Redis. Find the secret that you want to rotate, and then click Details in the Actions column.

  3. In the Versions section, click Configure Rotation and configure the rotation policy.

    • Automatic rotation: If enabled, select a rotation period from 6 hours to 365 days.

    • Rotate now: Manually triggers an immediate rotation.

More operations

Account check

KMS can check whether the database account associated with a secret belongs to the configured Redis instance. A successful check indicates that the secret can be rotated. If the check fails, you must delete and recreate the Redis/Tair secret.

  1. Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose Resources > Secrets.

  2. Click the Database Secrets tab. Select an Instance ID. From the Type drop-down list, select ApsaraDB for Redis Secrets. Find the secret that you want to check, and then click Details in the Actions column.

  3. In the Versions section, click Check Account. After the check is complete, view the result.

Delete a Redis/Tair secret

Warning

Before you delete a secret, make sure it is no longer in use. Deleting an active secret may cause your applications to fail.

Two deletion methods are supported: scheduled deletion and immediate deletion. Deleting a Redis/Tair secret from KMS removes only the secret itself. It does not delete the corresponding database accounts from the Redis or Tair instance.

  1. Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose Resources > Secrets.

  2. Click the Database Secrets tab. Select an Instance ID. From the Type drop-down list, select Redis. Find the secret that you want to delete, and then click Schedule Deletion in the Actions column.

  3. In the Schedule Deletion dialog box, select a deletion method for the secret and click OK.

    • Schedule Deletion: Specify a recovery period of 7 to 30 days. The system deletes the secret after the recovery period ends.

    • Delete Immediately: The system immediately deletes the secret.

    During the recovery period, you can find the secret and click Restore Secret in the Actions column to cancel the deletion.

Configure credential tags

You can assign tags to credentials to organize and manage them. Each tag consists of a key-value pair (Key : Value), including a tag key (Key) and a tag value (Value).

Tag usage notes

  • A tag key or tag value can contain up to 128 characters, including letters, digits, forward slashes (/), backslashes (\), underscores (_), hyphens (-), periods (.), plus signs (+), equal signs (=), colons (:), at signs (@), and spaces.

  • A tag key cannot start with aliyun or acs:. This restriction does not apply to tag values.

  • Each credential can have up to 20 tags.

Procedures

Tag a single credential
  1. Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose Resources > Secrets.

  2. Click the tab for the corresponding credential type, select a Instance ID, and locate the target credential.

  3. Open the tag editor using one of the following methods:

    • Method 1: In the credential list, click the image.png icon in the Tags column for the target credential.

    • Method 2: Click Actions > Details to go to the credential details page, then click the image.png icon next to Tag.

  4. In the Edit Tag dialog box, enter the Tag Key and Tag Value, and click OK.

Tag multiple credentials in bulk
  1. Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose Resources > Secrets.

  2. Click the tab for the corresponding credential type, select a Instance ID, and select the credentials to operate on from the credential list.

    • Add tags: At the bottom of the credential list, click Add Tag, enter the Tag Key and Tag Value, and click OK.

    • Delete tags: At the bottom of the credential list, click Remove Tag, select the tags to unbind in the Batch Remove dialog box, click Cancel, and then click Close in the confirmation dialog box.

FAQ