Updated on 2026-08-24 GMT+08:00

Enabling Key Rotation

KMS allows you to periodically rotate keys to enhance security for keys and service data. This section describes how keys are rotated in KMS and how to configure key rotation.

By default, automatic key rotation is disabled for a custom key. Every time you enable key rotation, KMS automatically rotates custom keys based on the rotation period you set. Once key rotation is enabled, certain fees will be charged. For details, see How Is Rotation Charged for a CMK?

Constraints

  • A disabled custom key is never rotated, even if rotation is enabled for it.

    KMS resumes rotation when this custom key is enabled. If you enable this custom key after one rotation period has passed, KMS will rotate it within 24 hours.

  • Only CMKs can be rotated.
  • Only symmetric keys can be rotated.
  • Key rotation is supported only for enabled keys with KMS-generated key materials.
  • Enabling key rotation for a custom key may incur additional fees. For details, see Billing Description.
  • A key material can be rotated for at most 100 times.

Enabling Key Rotation

For keys created on KMS, see Enabling Key Rotation for a Custom Key. For imported external key materials, see Rotating Key Materials of an External Key.

For an enabled custom symmetric key created on KMS, enable key rotation as follows:

Enabling key rotation incurs charges for each new key material. Choose a rotation period that balances your security compliance needs with your budget. You can set the system to automatically rotate keys every 90, 180, 270, or 365 days.

  1. Log in to the DEW console.
  2. Click in the upper left corner and select a region or project.
  1. Click the custom key name to access its details page.
  2. Click the Rotation Policy tab. The rotation switch is displayed.
  3. Click to enable key rotation.
  4. Configure the rotation period and click OK, as shown in Figure 3. For more information, see Table 3.

    Figure 3 Enabling key rotation
    Table 3 Key rotation parameters

    Parameter

    Description

    Key rotation

    Rotation switch. The default status is .

    : disabled

    : enabled

    After rotation is enabled, the key will be rotated based on your set period.

    NOTE:
    • A disabled custom key is never rotated, even if rotation is enabled for it.
    • KMS resumes rotation when this custom key is enabled. If you enable this custom key after one rotation period has passed, KMS will rotate it within 24 hours.

    Rotation Period (day)

    Rotation period (day). The value is an integer ranging from 30 to 365. The default value is 365.

    Configure the period based on how often a custom key is used. If it is frequently used, configure a short period. Otherwise, set a long one.

  5. Check rotation details, as shown in the following figure.

    Figure 4 Key rotation details

    You can click to change the rotation period. After the period is changed, KMS rotates the key by the new period.

For an enabled symmetric key using external key materials, enable key rotation as follows:

  1. Log in to the DEW console.
  2. Click in the upper left corner and select a region or project.
  3. Import new key materials.

    1. Locate the enabled external key and choose More > Import Key Material in the Operation column.
    2. In the Download the Import Items area, select a key wrapping algorithm based on Table 4.
      Figure 5 Obtaining the wrapping key and import token

      Table 4 Key wrapping algorithms

      Algorithm

      Description

      Configuration

      RSAES_OAEP_SHA_256

      RSA algorithm that uses OAEP and has the SHA-256 hash function

      Select an algorithm based on your HSM functions.

      If the HSMs support the RSAES_OAEP_SHA_256 algorithm, use it to encrypt key materials.

      Import key materials using either of the following ways:

      • Method 1: Use APIs to obtain the wrapping key and import token. Select Use Existing Key Material, and click Next. In the Import Key Material step, enter the key material content. Obtain the key materials by referring to Downloading the Wrapping Key By Calling APIs and Symmetric Keys.
        Figure 6 Importing key materials

      • Method 2: Select Download Key Material to download key materials to the local PC.

        The import token will be automatically imported. You only need to use the downloaded wrapping key to obtain the key material from your device. Do not close this dialog box, or the token will become invalid.

        Click Next. In the Import Key Material step, click Add to import local key materials.

        Figure 7 Importing key materials
    3. Click Next to go to the Import Key Token step. Configure the parameters by referring to Table 5.
      Figure 8 Importing a key token
      Table 5 Parameters for importing a key token

      Parameter

      Description

      Key ID

      Random ID of a key generated during key creation

      Key Material Expiration Mode

      You can only select Key material will never expire.

    4. Click OK.

  4. Enable key rotation.

    1. Locate the enabled external key and choose More > Rotate Now in the Operation column.
    2. In the displayed dialog box, click OK.

Disabling Key Rotation for a Custom Key

External keys can only be manually rotated.

  1. Click the custom key name to access its details page.
  2. Click the Rotation Policy tab.
  3. Click to disable key rotation.
  4. In the displayed confirmation dialog box, click OK.

Viewing Rotation Logs

You can view details about the key materials of symmetric keys.

Key material details are only available for symmetric keys.

  1. Click a key name to view its details.
  2. Click the Rotation Policy tab. The rotation switch is displayed.
  3. View the key material details, as shown in Figure 9.

    Figure 9 Key material information

Related Operations

For details about how to enable key rotation using an API, see Enabling Key Rotation.