All Products
Search
Document Center

Key Management Service:Purchase and enable a KMS instance

Last Updated:Aug 28, 2026

A KMS instance manages keys and secrets. Use keys to encrypt and decrypt sensitive data, and secrets to eliminate hardcoded credentials in your code.

Step 1: Purchase a KMS 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 > Instances.

  2. On the Instances page, click Create Instance, select a billing method and instance specifications, and click Buy Now.

    Subscription

    Parameter

    Description

    Site

    The site where the instance's region is located. Options: International regions and Chinese mainland regions.

    Key management type

    KMS provides free default keys (service keys and customer master keys) for cloud product encryption in each region. Default keys have limited features and require no instance purchase. You pay only for value-added services such as key rotation.

    Before purchasing, review Select a KMS instance type.

    • Purchase a KMS instance

      A software key management instance suits most use cases. Select a hardware key management instance if you need physical-level security or strict compliance such as financial regulations.

      • Software Key Management: Keys are stored in a dedicated database for your instance.

      • Hardware Key Management: Key generation, storage, encryption, and decryption rely on a dedicated Hardware Security Module (HSM) that is compliant with Chinese national cryptographic standards or FIPS 140-3 Level 3. If you select this type, you must also purchase an HSM. Configure an HSM cluster for a hardware key management instance.

    • Purchase value-added services for keys

      • Instance Backup: Software key management instances only. KMS provides free 90-day data backups by default. If this does not meet your needs, purchase the Instance Backup service. Backup management.

      • Default key rotation: Only free default keys require this value-added service. Default key rotation. If you purchased a KMS instance, the keys in the instance support rotation by default and do not require this value-added service.

    Region

    Select the same region as your deployed services. Regions and availability zones.

    Deployment mode

    KMS instances support dual-zone or multi-zone configurations for high availability, disaster recovery, and load balancing.

    Note
    • In the Philippines (Manila) and Thailand (Bangkok) regions, only a single zone is available, so KMS instances are deployed in a single zone by default.

    • A multi-zone deployment can be configured with up to three zones.

    For information about the number of zones in each region, see Regions and zones.

    Compute performance

    The performance specifications of the instance. For example, 2000 means up to 2,000 QPS for symmetric operations and 300 QPS for asymmetric operations independently.

    Note

    If you need a software key management instance with a compute performance of 10,000 or 20,000, contact us.

    Key quota

    The quota for keys. The default is 1,000.

    Counted by key versions, not keys. For example, one key with five versions uses five quota units.

    Secret quota

    The quota for secrets. The default is 0.

    Counted by secrets, regardless of version count.

    Note

    Skip this if you do not use secrets. You can add a secret quota later by upgrading.

    Data key quota

    The quota for data keys (DK). The default is 0.

    Counted by data key versions, not data keys. For example, one data key (DK) with five versions uses five quota units.

    Access management count

    This quota applies to two features:

    • Access a KMS instance from multiple VPCs in the same region: Allows multiple VPCs in the same region to access KMS resources. One quota unit is required for each VPC.

    • Share a KMS instance across multiple accounts: The number of quota units you need equals the number of Alibaba Cloud accounts with which you share the instance.

    Example: associating with three VPCs and sharing with two accounts requires a quota of at least 5.

    Default: 1 (the bound VPC).

    Log analysis

    Whether to enable log analysis. Log Service overview.

    Warning

    Log analysis cannot be disabled once enabled. Check for costs.

    Log storage capacity

    Minimum 1,000 GB, expandable in 1,000 GB increments. For capacity evaluation, please refer to Estimate your storage capacity.

    Quantity

    Number of KMS instances to purchase.

    Important

    One instance is sufficient for most use cases. To purchase multiple instances, contact us.

    Duration

    Subscription duration.

    Note

    You can select Auto-renewal on expiration for automatic renewal.

    Pay-as-you-go

    Parameter

    Description

    Site

    The site where the instance's region is located. Options: International regions and Chinese mainland regions.

    Key management type

    A software key management instance suits most use cases. Select a hardware key management instance if you need physical-level security or strict compliance such as financial regulations.

    • Software Key Management: Keys are stored in a dedicated database for your instance.

    • Hardware Key Management: Key generation, storage, encryption, and decryption rely on a dedicated Hardware Security Module (HSM) that is compliant with Chinese national cryptographic standards or FIPS 140-3 Level 3. If you select this type, you must also purchase an HSM. For more information, see Configure an HSM cluster for a hardware key management instance.

    Region

    Select the same region as your deployed services. Regions and availability zones.

    Compute performance

    The performance specifications of the instance.

    Key quota

    The quota for keys. The default is 1,000.

    Counted by key versions, not keys.

    Secret quota

    The quota for secrets. The default is 0.

    Note

    Skip this if you do not use secrets. You can add a secret quota later by upgrading.

    After purchase, go to the Instances page to enable the 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 > Instances.

    2. On the Instances page, click Create Instance, find the target KMS instance, and click Enable in the Actions column.

    3. In the Connect to HSM panel, configure the settings and then click Connect to HSM to specify the HSM cluster.

      1. Instance Name: A custom name for the KMS instance. The name can contain letters, digits, and the following special characters: _/+=.@-.

      2. Select Cluster: Select the HSM cluster that you configured in CloudHSM.

        Note

        A hardware key management instance can be bound to only one HSM cluster.

    4. Enablement takes about 30 minutes. Refresh the page to confirm the instance status changes to Enabled.

Step 2: Enable a KMS instance

After you purchase a KMS instance, you must enable it before you can use key management and secret management features.

Enable a software key management instance

Prerequisites

  • Network configuration: Ensure that you have one VPC and one vSwitch. To create a VPC and a vSwitch, see Create a VPC and a vSwitch or Create a vSwitch.

    Note

    You can log on to the VPC console to view existing VPCs, vSwitches, and the availability zones of the vSwitches.

  • PrivateZone configuration: If you use an Alibaba Cloud account for the Chinese mainland site (aliyun.com) to purchase a KMS instance in a region outside the Chinese mainland, or if you use an Alibaba Cloud account for the international site (alibabacloud.com) to purchase a KMS instance in a region within the Chinese mainland, you must manually activate PrivateZone. Activate PrivateZone.

    Note
    • If you use an Alibaba Cloud account for the Chinese mainland site (aliyun.com) to purchase a KMS instance in a region within the Chinese mainland, or if you use an Alibaba Cloud account for the international site (alibabacloud.com) to purchase a KMS instance in a region outside the Chinese mainland, PrivateZone is activated automatically.

    • KMS covers the DNS resolution fees. You are not charged by PrivateZone.

Procedure

  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 > Instances.

  2. On the Software Key Management tab, find the target software key management instance and click Enable in the Actions column.

  3. In the Connect to HSM panel, configure the parameters and click Connect to HSM.

    Parameter

    Description

    Instance Name

    Custom name for the KMS instance. Supported characters: letters, digits, and the following special characters: _/+=.@-.

    VPC ID

    Select the VPC to bind to the KMS instance.

    Configure Zone and vSwitch

    Depends on the deployment mode selected at purchase. Up to three availability zones can be configured for multi-zone mode.

    • Zone and vSwitch: Configure a single availability zone and a vSwitch. Ensure the vSwitch has at least one available IP address.

    • Other Zones: Supports random assignment or manual specification.

    Note
    • Some regions offer only one availability zone, so the KMS instance can only be deployed in a single zone.

    • Dual-zone and multi-zone deployments support high availability, disaster recovery, and load balancing. Performance and latency differences between business zones and non-business zones are negligible.

  4. Wait about 30 minutes, then refresh the page. When the status changes to Enabled, the software key management instance is enabled.

Enable a hardware key management instance

Scope

  • Network configuration requirements: Ensure a vSwitch is available in each availability zone of the KMS instance. The following assumes a dual-zone deployment.

    Note

    You can log on to the VPC console, click the target vSwitch on the vSwitch page, and view the number of available IP addresses on the details page.

    • Use the two vSwitches that are bound to the HSM instance: No new vSwitches needed. Ensure each vSwitch has at least four available IP addresses.

    • Do not use the two vSwitches that are bound to the HSM instance: Create two vSwitches in different availability zones, each with at least four available IP addresses. .

  • PrivateZone configuration requirements: If you use an Alibaba Cloud account for the Chinese mainland site (aliyun.com) to purchase a KMS instance in a region outside the Chinese mainland, or if you use an Alibaba Cloud account for the international site (alibabacloud.com) to purchase a KMS instance in a region within the Chinese mainland, you must manually activate PrivateZone. Activate PrivateZone.

    Note
    • If you use an Alibaba Cloud account for the Chinese mainland site (aliyun.com) to purchase a KMS instance in a region within the Chinese mainland, or if you use an Alibaba Cloud account for the international site (alibabacloud.com) to purchase a KMS instance in a region outside the Chinese mainland, PrivateZone is activated automatically.

    • KMS covers DNS resolution fees, so PrivateZone does not charge you.

Procedure

Purchased without HSM configured

  1. Go to the CloudHSM console to configure an HSM cluster for the KMS instance. Configure an HSM cluster.

    Warning

    To add HSMs to the cluster later, contact Alibaba Cloud technical support to switch the synchronization method to automatic to prevent failures.

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

  3. Click the Hardware Key Management tab, find the target hardware key management instance, and click Enable in the Actions column.

  4. In the Connect to HSM panel, configure the settings and then click Connect to HSM to specify the HSM cluster.

    • Instance Name: A custom name for the KMS instance. The name can contain letters, digits, and the following special characters: _/+=.@-.

    • Select Cluster: Select the HSM cluster that you configured in CloudHSM.

      Note

      A hardware key management instance can be bound to only one HSM cluster.

    • Configure HSM Access Secret.:

      Chinese mainland HSM

      • Automatically generate certificates: If you select Automatically generate certificates when purchasing an HSM in the Chinese mainland, HSM generates the required certificates automatically.

      • Manually generate certificates: If automatic certificate generation was not configured, you must configure a client certificate (PKCS#12 with protection password) and a security domain certificate (PEM-formatted CA certificate for the HSM cluster's TLS server certificate). Generate certificates and configure mutual TLS authentication.

        • Client Protection Password: The protection password that you set when you generate the client.p12 client certificate. If you use the certificate generation tool (hsm_certificate_generate), the default password is 12345678.

        • Client Certificate: A PKCS#12 certificate. Click Select File and select the generated client.p12 file to upload.

        • Security Domain Certificate: A PEM-formatted CA certificate. Click Select File and select the generated rootca.pem file to upload.

      International HSM

      • Automatically generate certificates: If you select Automatically generate certificates when purchasing an HSM outside the Chinese mainland, HSM generates and deploys the certificates to the server-side HSM. You only need to configure the corresponding certificates on the client SDK.

      • Manually generate certificates: If automatic certificate generation was not configured, manually configure the client certificate. Import a GVSM (NIST FIPS) cluster certificate.

        • Username: The username of the HSM operator. This is fixed to kmsuser.

        • Password: The password for the HSM operator. This is the password that you set when you create an HSM operator (CU user).

        • Security Domain Certificate: A PEM-formatted certificate. Log on to the CloudHSM console, click the ID of any HSM instance in the cluster, go to the Instance Details tab, and find the HSM Certificate section. Click ClusterOwnerCertificate and copy the content, or save it as a PEM file and then upload the file.

    • VPC: This defaults to the VPC ID that is bound to the HSM and cannot be changed.

    • Configure Zone and vSwitch: Depends on the deployment mode. Dual-zone and multi-zone deployments are supported. Each vSwitch must have at least four available IP addresses.

      Multi-zone deployments support up to three availability zones.

      Note

      Multi-zone deployments provide high availability, disaster recovery, and load balancing. Latency and performance differences between zones are negligible.

  5. After configuration, wait for the system to process. The instance is enabled when its status changes to Enabled.

    Note

    Enablement takes about 30 minutes with a secret quota, or about 10 minutes without. Refresh the page to see the updated status.

Enable an external key management instance

Prerequisites

  • HSM configuration requirements:

    • You have purchased an off-cloud HSM.

    • You have configured an XKI Proxy external proxy. The following connection methods are supported. For specific instructions, contact your HSM provider.

      • Public network connection: A direct connection is established over the public internet.

      • VPC endpoint connection: Create an endpoint service first by following Create and manage endpoint services.

        • Service Resource TypeCLB or NLB

        • Service Resource: The availability zones configured for the endpoint service must match the availability zones selected when launching the KMS instance.

        • Whitelist Configuration: Add your current Alibaba Cloud Account ID to the whitelist of the endpoint service.

        • Automatically Accept Endpoint Connections: Set to Yes.

  • PrivateZone configuration requirements: If you use an Alibaba Cloud account for the Chinese mainland site (aliyun.com) to purchase a KMS instance in a region outside the Chinese mainland, or if you use an Alibaba Cloud account for the international site (alibabacloud.com) to purchase a KMS instance in a region within the Chinese mainland, you must manually activate PrivateZone. Activate PrivateZone.

    Note
    • If you use an Alibaba Cloud account for the Chinese mainland site (aliyun.com) to purchase a KMS instance in a region within the Chinese mainland, or if you use an Alibaba Cloud account for the international site (alibabacloud.com) to purchase a KMS instance in a region outside the Chinese mainland, PrivateZone is activated automatically.

    • KMS covers DNS resolution fees, so PrivateZone does not charge you.

Procedure

  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 > Instances.

  2. Click the External Key Management tab, find the target instance, and click Enable in the Actions column.

  3. In the Connect to HSM panel, configure the settings and then click Connect to HSM to specify the HSM cluster.

    Parameter

    Description

    Instance Name

    A custom name for the KMS instance. The name can contain letters, digits, and the following special characters: _/+=.@-.

    VPC

    Select a VPC to bind to the KMS instance.

    Zone Configuration

    Depends on your deployment mode. Dual-zone and multi-zone (up to three) deployments are supported.

    • Zone and vSwitch: Configure an availability zone and a vSwitch. Make sure that the vSwitch has at least one available IP address.

    • Other Zones: Assign availability zones randomly or specify them manually.

    Note
    • Some regions have only one availability zone, limiting deployment to a single zone.

    • Multi-zone deployments provide high availability, disaster recovery, and load balancing. Latency and performance differences between zones are negligible.

    External Proxy Connectivity

    • Public Endpoint Connectivity: The KMS instance connects to the XKI Proxy external proxy over the public internet.

    • VPC Endpoint Service Connectivity : The KMS instance connects to the XKI Proxy external proxy by using a VPC endpoint service.

    Domain Name of External Proxy

    This parameter is required only if you set External Proxy Connectivity to Public Endpoint Connectivity. Enter the domain name of the XKI Proxy external proxy.

    Endpoint Service

    This parameter is required only if you set External Proxy Connectivity to VPC Endpoint Service Connectivity . Select an endpoint service.

    Note

    The availability zones selected for the KMS instance must be the same as the availability zones of the endpoint service. For more configuration details, see VPC Endpoint Connection Configuration Guide.

    External Proxy Configuration

    • Manual Configuration: Manually configure the External Proxy Path, Certificate Fingerprint, AccessKey ID, and AccessKey secret of the XKI proxy.

    • Configuration File Upload: Configure the parameters by uploading a configuration file.

    Enablement takes about 30 minutes with a secret quota, or about 10 minutes without. Refresh the page. The instance is enabled when its status changes to Enabled.

Unsubscribe from a KMS instance

KMS supports partial refund unsubscription for instances in the Pending Enable or Enabled state. Full refunds are not available.

  1. Go to the Refund page under Expenses > Refunds in the Alibaba Cloud console.

  2. On the Resources tab, set Product to Key Management Service (KMS), find the target instance, and click Unsubscribe in the Actions column.

  3. Review the resource information, refund terms, and refund amount on the confirmation page.

  4. Select the confirmation checkboxes (confirm the refund amount and confirm that data has been backed up and migrated) on the lower-left, then click Confirm Unsubscription.

Warning

Unsubscription is irreversible. Make sure to back up your keys and secrets before proceeding.

Troubleshooting

Troubleshoot software key enablement errors

Error message

Possible cause

Solution

Your VSwitches don't have enough ip address create dedicate kms instance.

Insufficient available IP addresses in the vSwitch.

Establishing the private network communication link for a KMS instance consumes one IP address from the vSwitch. The current vSwitch has zero available IPs.

Note

Log on to the VPC console, click the target vSwitch on the vSwitch page, and view the number of available IP addresses on the details page.

Select a different vSwitch and ensure that the vSwitch has at least one available IP address.

500:Internal Failure

PrivateZone is not activated.

KMS usually auto-activates PrivateZone, but manual activation is required in the following scenarios:

  • Use an Alibaba Cloud account for the Chinese mainland site (aliyun.com) to purchase a KMS software key management instance outside the Chinese mainland.

  • Use an Alibaba Cloud account for the international site (alibabacloud.com) to purchase a KMS software key management instance within the Chinese mainland.

Manually activate PrivateZone. For more information, see Activate Alibaba Cloud DNS PrivateZone.

Note

KMS covers the DNS resolution fees. You are not charged by PrivateZone.

Troubleshoot hardware key enablement errors

Error message

Possible cause

Solution

Your VSwitches don't have enough ip address create dedicate kms instance.

Insufficient available IP addresses in the vSwitch.

  • Establishing the private network communication link for a KMS instance consumes one IP address from the vSwitch.

  • KMS creates 2 to 4 ENIs for communication between the KMS instance and the HSM cluster. Each ENI occupies one IP address in the vSwitch.

Note

Log on to the VPC console, click the target vSwitch on the vSwitch page, and view the number of available IP addresses on the details page.

Select a different vSwitch and ensure that the vSwitch has at least five available IP addresses.

500:Internal Failure

PrivateZone is not activated.

KMS usually auto-activates PrivateZone, but manual activation is required in the following scenarios:

  • Use an Alibaba Cloud account for the Chinese mainland site (aliyun.com) to purchase a KMS hardware key management instance outside the Chinese mainland.

  • Use an Alibaba Cloud account for the international site (alibabacloud.com) to purchase a KMS hardware key management instance within the Chinese mainland.

Manually activate PrivateZone. For more information, see Activate Alibaba Cloud DNS PrivateZone.

Note

KMS covers the DNS resolution fees. You are not charged by PrivateZone.

FAQ

  • What is a KMS-managed HSM?

    A KMS-managed HSM is an HSM instance that KMS automatically creates when you purchase a hardware key management instance, based on the HSM configuration you provide at the time of purchase.

  • Can I scale out a KMS-managed HSM cluster?

    No. You can only perform backup operations. All other operations are not supported.

  • Why does the instance keep showing "Connecting" during enablement?

    When enabling a KMS instance (including software key management instances and hardware key management instances), wait about 30 minutes and then refresh the page. When the instance status changes to Enabled, the KMS instance is enabled.

  • What if I see "Connection failed" when enabling a hardware key management instance?

    Check whether the HSM access credentials are correct. For more information about HSM access credentials, see Create and activate a cluster.

  • What do I do if I get a "ZoneIds is not valid" or "vswitch_ids invalid" error when enabling a KMS instance using IAC or API?

    This error typically occurs when the zone or vSwitch parameters you pass do not match the KMS instance specifications. The following describes two common scenarios and their solutions:

    • Scenario 1: Availability zone count mismatch

      This error is triggered when you purchase a dual-zone KMS instance but pass three zone IDs (ZoneIds) in an IAC Stack or API call.

      Solution: Verify the number of zones supported by your instance specification. If you need to configure three zones, purchase an instance specification that supports multi-zone deployment.

    • Scenario 2: Incorrect vSwitch parameter

      This error is triggered when you pass multiple vswitch_ids values in a DKMS ConnectKmsInstance API call or Terraform configuration. The ConnectKmsInstance API only accepts a single vSwitch ID.

      Solution: Modify your configuration to pass only a single vSwitch ID (vswitch_id), then retry the operation.