AWS Key Management Service (AWS KMS) supports the security certifications, algorithms, and performance that most AWS CloudHSM workloads require. Organizations that migrate from AWS CloudHSM to AWS KMS have significantly reduced costs while eliminating hardware security module (HSM) provisioning, patching, and high-availability management. For a detailed comparison of both services, see AWS KMS or AWS CloudHSM: Choose the right key management solution. For payment workloads, see AWS Payment Cryptography in the following table.

Is migration right for you?

Most AWS CloudHSM workloads can migrate to AWS KMS. The following requirements might appear to need CloudHSM, but most have a resolution path:

Potential requirement Resolution
Contractual or compliance mandate requiring single-tenant HSMs Review your compliance documentation for explicit single-tenant language; many organizations find that it’s assumed, not mandated. Where mandated, a security review of AWS KMS typically confirms that its logical cryptographic isolation architecture satisfies the underlying intent.
Applications that rely on traditional HSM interfaces (PKCS#11, Java Cryptography Extension, OpenSSL Provider, or Key Storage Provider) These interfaces are a communication pattern, not an architectural constraint. Contact your AWS account team to assess the refactoring effort needed for your workloads to use modern RESTful interfaces to web services.
Deprecated algorithms (TDES, PKCS#1 v1.5 with RSA) or less common operations (AES key wrapping, AES-CTR, AES-CBC) Evaluate whether you can retire the dependency as part of your security modernization.
Over 1 billion cryptographic operations per month, where higher per-operation AWS KMS costs might favor the per-hour AWS CloudHSM cost model Per-operation pricing is only one of several factors that affect cost. Also consider saved staff time, patching, and high-availability management. With envelope encryption (Option B in the following section), optional data key caching can further reduce API call volume.
Payment workloads using older or payment-specific cryptography (TDES, AES-CBC) While AWS KMS embeds cryptographic best practices in a managed service, some payment systems still rely on older cryptography such as TDES. Evaluate Payment Cryptography, which supports payment use cases, including TDES-based algorithms such as CVV2, ARQC, and PIN validation. It also provides low-level algorithms, such as AES-CBC, that third-party systems might require for interoperability.

If you can resolve these requirements, it’s possible to migrate from AWS CloudHSM to AWS KMS. You can use the rest of this post to review the basic steps of migration to AWS KMS.

How migration works

Migration has three parts: updating application code to call KMS APIs, rotating or importing your cryptographic keys, and transitioning existing data. You re-encrypt previously encrypted data under KMS keys, and existing signatures remain verifiable without AWS CloudHSM. You can complete each part gradually, with zero downtime. Application refactoring is the bulk of the effort, though AI-assisted code transformation tools can reduce this work. Because you’re already refactoring application code, this migration is also an opportunity to adopt post-quantum cryptography (PQC) algorithms, discussed in the following section.

Digital signature workloads

During the transition, the AWS CloudHSM private key continues to sign existing workloads. If AWS CloudHSM lets you export (wrap) a copy of your private key, import it directly into AWS KMS to maintain continuity. For details, see How to Migrate Asymmetric Keys from CloudHSM to AWS KMS. If the key is non-exportable, create a new key pair in AWS KMS. A new asymmetric KMS key (or the imported key from CloudHSM) signs new data flowing to AWS KMS. Shift traffic from AWS CloudHSM to AWS KMS at your own pace. If you created a new key pair, export the CloudHSM public key before decommissioning and use it to verify existing signatures locally with libraries such as AWS-LC or OpenSSL as shown in Figure 1. AWS KMS doesn’t support importing public keys.

Figure 1 - Digital signature migration

Figure 1 – Digital signature migration

Post-quantum readiness: When creating new signing keys in AWS KMS as part of this migration, consider adopting post-quantum cryptography (PQC). AWS KMS supports ML-DSA (FIPS 204), so you can begin issuing PQC signatures now rather than as a separate future effort. This matters most for long-lived signatures, such as document signing, code signing, and certificate issuance.

Durability of imported asymmetric keys: Asymmetric key material imported into AWS KMS (using ImportKeyMaterial) doesn’t have the same durability guarantees as keys generated within AWS KMS. In the unlikely event of an AWS Region-wide infrastructure failure, imported key material could become unavailable. To protect against this, create the key as a multi-Region key, then import the same key material into each replica key in other Regions. Also keep secure backups of imported private keys outside of AWS KMS. An AWS CloudHSM cluster backup is a zero-cost option; CloudHSM stores backups in Amazon Simple Storage Service (Amazon S3) at no additional charge. For keys created in AWS KMS (not imported), AWS KMS automatically manages durability within a Region, and multi-Region keys replicate the key material for you.

Encryption workloads

For encryption workloads, use the gradual re-encryption pattern: encrypt new data with AWS KMS while a background process re-encrypts existing data created under AWS CloudHSM keys. This achieves a zero-downtime migration. The following are two approaches to gradual re-encryption, depending on your requirements.

Option A: Direct encryption with AWS KMS API (recommended)

Call the AWS KMS Encrypt and Decrypt APIs directly (Figure 2). Your application passes plaintext to kms:Encrypt and receives a self-contained ciphertext blob. To decrypt, pass the blob to kms:Decrypt. There are no data keys to manage, no local cryptography, and no libraries beyond the AWS SDK. When decrypting, AWS KMS identifies the correct key from metadata it embeds in the ciphertext, including the key material identifier. As a result, ciphertext produced by AWS KMS is larger (by about 150 bytes) than AWS CloudHSM would produce for the same plaintext. During transition, your application must handle data encrypted by both systems. On decrypt, call kms:Decrypt first. If the ciphertext was created by kms:Encrypt, it will succeed. If it was created by CloudHSM, kms:Decrypt will return InvalidCiphertextException immediately without attempting decryption. Your application then falls back to the CloudHSM decrypt path and can optionally re-encrypt the plaintext with kms:Encrypt and store the new ciphertext. All new encrypt operations go to AWS KMS immediately; only decrypt needs the fallback until re-encryption is complete.

The following pseudocode illustrates this pattern:

def encrypt_record(record_id, record): response = kms.encrypt(KeyId=kms_key_arn, Plaintext=record) store(record_id, ciphertext=response['CiphertextBlob']) def decrypt_record(record_id): stored = fetch(record_id) try: response = kms.decrypt(CiphertextBlob=stored.ciphertext) return response['Plaintext'] except kms.exceptions.InvalidCiphertextException: # Not a KMS ciphertext - fall back to CloudHSM return cloudhsm_decrypt(stored.ciphertext)
Figure 2 - Encryption migration with AWS KMS API

Figure 2 – Encryption migration with AWS KMS API

More about AWS KMS encryption

  • AWS KMS direct encryption supports plaintext up to 4 KB per request. For larger payloads, use Option B (AWS Encryption SDK), which handles envelope encryption for you and supports data of any size.
  • AWS KMS also supports asymmetric encryption with RSA keys for use cases such as encrypting data destined for a specific key pair holder. This post focuses on symmetric encryption because it covers the majority of AWS CloudHSM encryption workloads.

Option B: Envelope encryption with AWS Encryption SDK

For workloads that require envelope encryption, use the AWS Encryption SDK as shown in Figure 3. Your application calls encrypt() on plaintext and decrypt() on ciphertext. The SDK manages data key generation, local 256-bit AES-GCM encryption, and serialization automatically. Its portable ciphertext format works across multiple runtimes of the AWS Encryption SDK. You can also enable data key caching to reduce calls to AWS KMS. Use this approach when you share encrypted data across services, languages, or with third parties outside of AWS.

Figure 3 - Encryption migration with AWS Encryption SDK

Figure 3 – Encryption migration with AWS Encryption SDK

Migration results

A financial services company migrated their transaction data encryption from AWS CloudHSM to AWS KMS. Prior to migration, their workload ran 75 million cryptographic operations per month on three HSMs provisioned for high availability and the operational burden was 25 hours per month. After the migration, they no longer had to manage HSMs, which reduced their operational burden to near zero.

Metric Before (AWS CloudHSM) After (AWS KMS)
Monthly cost $3,456 (three HSMs) Approximately $250 (93% reduction)
Operational burden 25 hours per month (patching, certificates, and monitoring) Near zero: no HSMs to manage
Compliance FIPS 140-3 Level 3 FIPS 140-3 Level 3
Disaster recovery Multi-Availability Zone (AZ) HSMs that they provisioned, sized, and monitored Automatic multi-AZ availability. Optional multi-Region replication
Migration duration – 10 weeks, zero downtime

Recommendations

We recommend the following as you migrate from AWS CloudHSM to AWS KMS.

  • Use AI-assisted code transformation tools to accelerate refactoring and reduce manual effort.
  • Run the complete migration in staging first, including re-encryption of representative data volumes.
  • Document specific rollback criteria. During gradual re-encryption, you can pause at any point while AWS CloudHSM continues to decrypt data that has not yet moved. Keep KMS keys enabled after a rollback, because data already re-encrypted under AWS KMS still needs them.
  • Design AWS Identity and Access Management (IAM) policies, key policies, grants, and encryption context schemas before migration. Encryption context enables fine-grained audit trails not available in CloudHSM. See the AWS KMS Developer Guide for a list of log entries.
  • Delete CloudHSM keys only after all data is re-encrypted and verified. Before deleting, create a CloudHSM cluster backup of any keys imported into AWS KMS and export the public key of any signing key you replaced. Maintain an audit trail of the decommissioning.

Next steps

Start by auditing your current AWS CloudHSM usage: document your keys, the applications that use them, your monthly operation volume, and any compliance constraints. Use the AWS Pricing Calculator to estimate AWS KMS costs for your workload, then test a proof-of-concept migration with a non-critical application.

Conclusion

Migrating from AWS CloudHSM to AWS KMS removes the recurring work of provisioning, scaling, patching, and monitoring HSM clusters, freeing your team to focus on your application rather than the cryptographic infrastructure beneath it. You gain built-in high availability across multiple Availability Zones, with optional multi-Region replication, at a usage-based cost rather than a per-hour commitment for hardware you manage. Because the migration involves refactoring application code, it is also a natural point to adopt post-quantum signing algorithms such as ML-DSA, so you modernize your security posture in the same effort.

For implementation support, contact your AWS account team or AWS Professional Services. For API integration details, see the AWS KMS Developer Guide.


If you have questions about this post, contact AWS Support or start a new thread on AWS re:Post.

Derek Tumulak

Derek Tumulak

Derek Tumulak is a seasoned cybersecurity leader and Principal Product Manager at Amazon Web Services. With over 20 years of experience, he has held executive roles at Thales and Vormetric. A University of Waterloo graduate, Derek is a recognized expert in data security and encryption, frequently advising Silicon Valley organizations on advanced technical strategies and product innovation.