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
Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose .
On the Instances page, click Create Instance, select the instance specifications, and click Buy Now.
General configuration
Parameter
Description
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-2 Level 3. If you select this type, you must also purchase an HSM. Configure an HSM cluster for a hardware key management instance.
External Key Management: Use keys from your external key management infrastructure to encrypt and decrypt data on Alibaba Cloud.
NoteCurrently, only HSMs from the vendor Jiangnan Tianan are supported. If you need to manage HSMs from other vendors, contact us.
Purchase value-added services for keys
Expert service: One-on-one expert consultation, monitoring, and KMS 1.0-to-3.0 migration to ensure stable KMS-integrated applications.
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: Default keys do not support automatic rotation. Purchase this service to enable it. Default key rotation.
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.
NoteIn 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.
NoteIf 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.
NoteSkip this if you do not use secrets. You can add a secret quota later by upgrading.
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.
WarningLog 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.
ImportantOne instance is sufficient for most use cases. To purchase multiple instances, contact us.
Duration
Subscription duration.
NoteYou can select Auto-renewal on expiration for automatic renewal.
Hardware Key ManagementExclusive configuration
NoteTo purchase a virtual HSM instead, follow Purchase an HSM. To purchase a dedicated HSM, contact Alibaba Cloud technical support.
Parameter
Description
Number of HSMs
Select the number of HSM instances to purchase. Two HSM instances are purchased by default.
Number of HSM Snapshots
The number of snapshots in the HSM backup. Each snapshot backs up HSM data once. HSMs managed by Hardware Key Management instances have data backup enabled by default.
ImportantThe HSM instance automatically backs up once daily at 00:00 (UTC+8), generating one snapshot. When the snapshot limit is reached, the system automatically overwrites the earliest snapshot.
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 .
NoteYou 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.
NoteIf 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
Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose .
On the Software Key Management tab, find the target software key management instance and click Enable in the Actions column.
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.
NoteSome 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.
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.
NoteYou 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.
NoteIf 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 with HSM configured
Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose .
Click the Hardware Key Management tab, find the target hardware key management instance, and click Enable in the Actions column.
In the Connect to HSM panel, configure the parameters and click Connect to HSM. The system automatically enables the HSM cluster.
Instance Name: Enter a custom name for the KMS instance. Supported characters: letters, digits, and special characters
_/+=.@-.VPC ID: Select the VPC ID to bind to the HSM.
Configure Zone and vSwitch: The available zones depend on the deployment mode selected at purchase (dual-zone or multi-zone). Each zone's vSwitch must have at least four available IP addresses. Up to three zones can be configured for multi-zone mode.
NoteDual-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.
HSM Data Recovery (Optional):
Restore from Specified HSM Image?: After this option is enabled, the system restores data from the HSM backup specified by the configured HSM Backup ID to the latest HSM associated with the hardware key management instance.
HSM Backup Region: Select the region where the target backup is stored.
HSM Backup ID: The ID of the backup to restore. You can view backup information on the Data Backup and Recovery Management page of the CloudHSM console.
Only backups from HSM instances managed by KMS are supported.
HSM Backup Image: Select the snapshot to restore. Select the latest backup to ensure data integrity.
After the configuration is complete, wait for the system to process. When the status changes to Enabled, the hardware key management instance and the associated HSM cluster are enabled. You can view the details of the associated HSM instances on the KMS instance details page.
If you selected a secret quota at purchase, wait about 30 minutes and then refresh the page. If you did not select a secret quota, wait about 10 minutes and then refresh the page.
Purchased without HSM configured
Go to the CloudHSM console to configure an HSM cluster for the KMS instance. Configure an HSM cluster.
WarningTo add HSMs to the cluster later, contact Alibaba Cloud technical support to switch the synchronization method to automatic to prevent failures.
Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose .
Click the Hardware Key Management tab, find the target hardware key management instance, and click Enable in the Actions column.
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.
NoteA 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.p12client certificate. If you use the certificate generation tool (hsm_certificate_generate), the default password is12345678.Client Certificate: A PKCS#12 certificate. Click Select File and select the generated
client.p12file to upload.Security Domain Certificate: A PEM-formatted CA certificate. Click Select File and select the generated
rootca.pemfile 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.
NoteMulti-zone deployments provide high availability, disaster recovery, and load balancing. Latency and performance differences between zones are negligible.
After configuration, wait for the system to process. The instance is enabled when its status changes to Enabled.
NoteEnablement 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.
NotePublic network connection: A direct connection is established over the public internet.
VPC endpoint connection: Create an endpoint service first. .
The two availability zones of the endpoint service must match the availability zones selected for the KMS instance.
You must add your current Alibaba Cloud account to the allowlist of the endpoint service.
The Automatically Accept Endpoint Connections setting for the endpoint service must be 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.
NoteIf 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
Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose .
Click the External Key Management tab, find the target instance, and click Enable in the Actions column.
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.
NoteSome 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.
The availability zones selected for the KMS instance must be the same as the availability zones of the endpoint service.
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.
Go to the Refund page under Expenses > Refunds in the Alibaba Cloud console.
On the Resources tab, set Product to Key Management Service (KMS), find the target instance, and click Unsubscribe in the Actions column.
Review the resource information, refund terms, and refund amount on the confirmation page.
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.
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:
| 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.
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:
| 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 Configure mutual TLS authentication for an HSM instance.
Can applications access a KMS instance across regions?
Yes. You need to purchase a software key management instance or a hardware key management instance, and establish a cross-region VPC connection and configure PrivateZone DNS resolution to integrate applications in other regions. For more information, see Configure cross-region access to KMS instances for applications.
NoteBefore implementation, we recommend that you evaluate the costs of VPC connection and PrivateZone, the service level agreement (SLA), bandwidth capacity, and propagation time, and develop a multi-region deployment plan that covers system architecture, network architecture, operations management, and emergency response procedures.
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_idsvalues in a DKMSConnectKmsInstanceAPI call or Terraform configuration. TheConnectKmsInstanceAPI only accepts a single vSwitch ID.Solution: Modify your configuration to pass only a single vSwitch ID (
vswitch_id), then retry the operation.