CLF-C02Chapter 70 of 130Objective 2.3

AWS Key Management Service (KMS)

This chapter covers AWS Key Management Service (KMS), a managed service that makes it easy to create and control encryption keys used to encrypt your data. For the CLF-C02 exam, this falls under Domain 2: Security and Compliance, which is weighted at 25% of the exam. Understanding KMS is critical because encryption is a fundamental security control, and the exam tests your ability to distinguish KMS from other encryption services like AWS CloudHSM and the AWS Encryption SDK. By the end of this chapter, you'll know how KMS works, its key components, pricing, and exactly what the exam expects you to know.

25 min read
Intermediate
Updated May 31, 2026

The Corporate Safe with Master Keys

Imagine you run a large corporation with hundreds of departments, each storing sensitive documents in their own filing cabinets. Every cabinet has a unique lock, and each department manages its own keys. This works, but it's chaotic: keys get lost, copied without permission, and there's no central oversight. Now picture a single, ultra-secure vault room in the headquarters. This vault holds master key blanks that can create keys for any filing cabinet, but the master keys themselves never leave the vault. When a department needs a key, they submit a request to the vault. The vault's security guard verifies the request, then uses a master blank to cut a new key and hands it to the department. The department can lock and unlock its cabinet, but they never see or touch the master blank. If a key is compromised, the vault can instantly disable it and issue a new one without changing the cabinet lock. The vault also keeps an audit log of every key cut and every access. This is AWS KMS: the vault is the KMS service, the master blanks are Customer Master Keys (CMKs), the cabinet locks are data keys, and the security guard is AWS's hardware security modules (HSMs) that protect the master keys. You control who can request keys via IAM policies, and AWS rotates the master keys automatically. The key insight: the master key never leaves the HSM; you only get encrypted data keys to use locally.

How It Actually Works

What is AWS KMS and the Problem It Solves

AWS Key Management Service (KMS) is a managed service that lets you create, manage, and control cryptographic keys for encrypting data across AWS services and in your applications. Before KMS, customers had to manage their own encryption keys using on-premises hardware security modules (HSMs) or software-based key management systems. This was complex, expensive, and error-prone. Keys could be lost, stolen, or misconfigured, leading to data breaches or permanent data loss. KMS solves this by providing a centralized, highly available, and durable key management infrastructure that integrates with over 50 AWS services, including S3, EBS, RDS, and Lambda.

KMS uses FIPS 140-2 validated hardware security modules (HSMs) to protect your keys. The service is multi-tenant, meaning AWS manages the underlying HSMs, but your keys are isolated using cryptographic boundaries. KMS is region-specific: keys are created in a particular AWS region and never leave that region unless you explicitly replicate them.

How KMS Works — Core Concepts

At the heart of KMS are Customer Master Keys (CMKs). A CMK is a logical representation of a master key. It contains metadata (key ID, creation date, description, key state) and a reference to the actual cryptographic material stored in HSMs. CMKs can be symmetric (AES-256) or asymmetric (RSA or elliptic curve). Symmetric CMKs are used for encrypting data keys and for envelope encryption. Asymmetric CMKs are used for sign/verify or encrypt/decrypt operations where the public key can be shared.

CMKs come in two types: AWS managed and customer managed. AWS managed CMKs are created automatically by AWS services (e.g., S3, EBS, RDS) when you enable encryption for that service. You cannot manage these keys—AWS handles rotation, permissions, and deletion. Customer managed CMKs are created by you. You have full control over key policies, rotation, and deletion. There is also a third type: AWS owned keys, which are not visible to you and are used by AWS services for internal encryption.

When you create a customer managed CMK, you can choose the key spec (symmetric or asymmetric), the key usage (encrypt/decrypt or sign/verify), and the origin (AWS KMS or external key store). You can also enable automatic rotation (yearly for symmetric CMKs). The key material never leaves the HSMs; you interact with the CMK via API calls.

Envelope Encryption and Data Keys

KMS uses envelope encryption to encrypt large amounts of data. Instead of encrypting your data directly with the CMK (which is limited to 1 MB per API call for symmetric encryption), you generate a data key from the CMK. A data key is a symmetric key (typically AES-256) that you use to encrypt your data locally. KMS returns two versions: a plaintext data key and an encrypted copy of the same key. You use the plaintext key to encrypt your data, then discard it. You store the encrypted data key alongside the encrypted data. To decrypt, you send the encrypted data key to KMS, which decrypts it using the CMK and returns the plaintext data key. You then use that to decrypt your data. This way, the CMK is never exposed, and you can encrypt arbitrarily large data.

Key Policies and Grants

Access to CMKs is controlled by key policies and IAM policies. Key policies are resource-based policies attached directly to the CMK. They define who can use the key and under what conditions. Every CMK must have exactly one key policy. IAM policies can also grant access to CMKs, but only if the key policy explicitly allows the root user to delegate access via IAM. This is a common exam trap: if the key policy does not allow IAM, IAM policies alone cannot grant access.

Grants are another way to delegate access. A grant is a one-time permission that allows a principal to use a CMK for a specific operation. Grants are used by AWS services (like S3) to encrypt/decrypt on your behalf. They are temporary and can be retired.

Key States and Lifecycle

CMKs can be in several states: Enabled, Disabled, Pending Deletion, Pending Import, and Unavailable. An enabled key can be used for cryptographic operations. A disabled key cannot be used. When you delete a CMK, it enters a Pending Deletion state for a waiting period (default 30 days). During this time, you can cancel deletion. After the waiting period, AWS deletes the key material permanently. This is irreversible—any data encrypted with that key becomes unrecoverable. The exam loves to test that deletion is not immediate and has a waiting period.

Pricing

KMS pricing is based on the number of CMKs you create and the number of API calls you make. Customer managed CMKs cost $1 per month per key (prorated hourly). AWS managed CMKs are free. API calls cost $0.03 per 10,000 requests (for symmetric encrypt/decrypt). Asymmetric operations cost more. There is a free tier: 20,000 requests per month for AWS managed CMKs. The exam may ask about this pricing model, especially the free tier.

Comparison to On-Premises

On-premises key management requires purchasing HSMs, managing their lifecycle, ensuring high availability, and handling key rotation and backup. With KMS, you eliminate hardware costs, reduce operational overhead, and benefit from AWS's security posture. However, you give up control over the physical HSMs. If you need full control (e.g., for regulatory reasons), you can use AWS CloudHSM, which provides dedicated HSMs that you manage. CloudHSM is more expensive and complex but gives you single-tenant hardware.

When to Use KMS vs Alternatives

Use KMS when you need centralized key management, integration with AWS services, and automatic key rotation. Use CloudHSM when you need FIPS 140-2 Level 3 (KMS is Level 2 overall, though some operations are Level 3) or when you need to store your own keys and manage them without AWS having access. Use the AWS Encryption SDK when you need client-side encryption with envelope encryption outside of AWS services. Use AWS Secrets Manager for managing secrets (passwords, API keys) rather than encryption keys.

Walk-Through

1

Create a Customer Managed CMK

Sign in to the AWS Management Console, navigate to KMS, and click 'Create a key'. Choose symmetric or asymmetric key type. For most use cases, symmetric is fine. Select key usage: Encrypt and Decrypt. Choose an alias (a friendly name like 'my-app-key') and optional description. Define key administrative permissions (who can manage the key) and key usage permissions (who can use the key for encrypt/decrypt). You can also choose to allow IAM policies to grant access. Review and create. Behind the scenes, AWS generates a new 256-bit AES key in an HSM, assigns a unique key ID (e.g., 1234abcd-12ab-34cd-56ef-1234567890ab), and stores it. The key material never leaves the HSM. The key is enabled by default and costs $1 per month.

2

Generate a Data Key Using the CMK

To encrypt a large file (e.g., a 1 GB database backup), you call the GenerateDataKey API, specifying the CMK ID. KMS returns a plaintext data key (a 256-bit AES key) and an encrypted copy of that same key (encrypted under the CMK). The plaintext key is returned in plaintext in memory—it is your responsibility to use it and then discard it. The encrypted data key (also called ciphertext blob) is typically stored alongside the encrypted file. AWS does not store the plaintext key anywhere. The API call costs $0.03 per 10,000 requests. You can also specify the key spec (AES_256 or AES_128).

3

Encrypt Data Locally with the Data Key

You use the plaintext data key to encrypt your data using an encryption algorithm like AES-GCM. This happens on your client side—AWS is not involved. After encryption, you securely delete the plaintext data key from memory. You then store the encrypted data key (ciphertext blob) with the encrypted data. For example, you might prepend the encrypted data key to the encrypted file, or store it in a metadata field. This ensures that the decryptor can later retrieve the encrypted data key and send it to KMS to get the plaintext key. The exam tests that the plaintext key should never be stored or transmitted in the clear.

4

Decrypt Data Using the CMK

To decrypt, you extract the encrypted data key from the stored data. You call the Decrypt API, passing the encrypted data key (ciphertext blob) to KMS. KMS uses the CMK to decrypt the ciphertext blob and returns the plaintext data key. You then use that plaintext key to decrypt the data locally. The Decrypt API call costs the same as encrypt. Note that you do not need to specify the CMK ID in the Decrypt call—KMS can derive the CMK from the ciphertext blob because it contains metadata. This is important for exam questions about how decryption works. If you have multiple CMKs, you can also explicitly specify the key ID.

5

Enable Automatic Key Rotation

For customer managed symmetric CMKs, you can enable automatic annual rotation. When enabled, KMS generates new cryptographic material for the CMK every year. The old material is retained for decryption of older data. The key ID, alias, and permissions remain the same. This is a one-click setting in the console. AWS managed CMKs are rotated automatically every three years (approximately). Asymmetric CMKs cannot be automatically rotated. The exam tests that automatic rotation is only available for symmetric CMKs and that it does not change the key ID. You can also manually rotate by creating a new CMK and updating your applications.

What This Looks Like on the Job

Scenario 1: Encrypting EBS Volumes for a Financial Application

A fintech company runs a critical application on EC2 instances with EBS volumes storing customer transaction data. They must encrypt all data at rest to comply with PCI DSS. They create a customer managed CMK and enable automatic rotation. When launching EC2 instances, they select 'Encrypt this volume' and choose their CMK. Behind the scenes, KMS generates a data key, encrypts the EBS volume with it, and stores the encrypted data key with the volume. The plaintext data key is sent to the EC2 instance's Nitro card (if using Nitro instances) or to the instance's memory (for older instances) to enable transparent encryption/decryption. The company also uses the same CMK to encrypt snapshots. Cost: $1 per month for the CMK plus API call costs. Misconfiguration: if they accidentally disable the CMK, the EBS volume becomes inaccessible, causing application downtime. They must ensure key policies allow the EC2 service to use the key via grants.

Scenario 2: Server-Side Encryption for S3 with SSE-KMS

A healthcare startup stores patient records in S3. They need to encrypt objects at rest and control who can decrypt them. They enable default bucket encryption with SSE-KMS using a customer managed CMK. When a user uploads an object, S3 calls KMS to generate a data key, encrypts the object, and stores the encrypted data key as metadata. When the object is downloaded, S3 calls KMS to decrypt the data key and then decrypts the object. The company also attaches an S3 bucket policy that only allows users with specific IAM roles to decrypt. They enable CloudTrail to audit all KMS API calls. Cost: $1 per month for the CMK plus $0.03 per 10,000 requests. Pitfall: if the CMK is deleted, all S3 objects encrypted with it become permanently unreadable. They set a waiting period of 30 days and use multi-Region keys for disaster recovery.

Scenario 3: Client-Side Encryption with AWS Encryption SDK

A gaming company stores player data in DynamoDB. They want to encrypt sensitive attributes (e.g., email addresses) before sending them to DynamoDB. They use the AWS Encryption SDK to perform client-side encryption. They create a CMK in KMS and use the SDK to generate a data key, encrypt the attribute, and store the encrypted data key alongside the encrypted value. The SDK handles the envelope encryption logic. The plaintext data key is never persisted. When reading, the SDK decrypts the data key using KMS and then decrypts the attribute. This gives them end-to-end encryption where even AWS cannot see the plaintext. Cost: same KMS pricing plus SDK overhead. Misconception: some think they need CloudHSM for client-side encryption, but KMS works fine.

How CLF-C02 Actually Tests This

What CLF-C02 Tests on KMS

The CLF-C02 exam covers KMS under Domain 2: Security and Compliance. You should understand the following:

The purpose of KMS: centralized key management, integration with AWS services, envelope encryption.

The difference between customer managed CMKs and AWS managed CMKs.

The concept of envelope encryption and data keys.

Key policies vs IAM policies—especially the condition that the key policy must allow IAM for IAM policies to work.

Key states: Enabled, Disabled, Pending Deletion (with 30-day waiting period).

Automatic key rotation: symmetric only, annual for customer managed, ~3 years for AWS managed.

Pricing: $1 per CMK per month (customer managed), free for AWS managed; $0.03 per 10,000 API requests; free tier of 20,000 requests per month.

Integration with other services: S3 (SSE-KMS), EBS, RDS, Lambda, etc.

Common Wrong Answers and Why Candidates Choose Them

1.

'KMS stores your encryption keys on disk.' Wrong. Keys are stored in HSMs and never leave them in plaintext. Candidates confuse KMS with traditional key storage.

2.

'You can use a CMK to encrypt data larger than 1 MB directly.' Wrong. The Encrypt API has a 1 MB limit. Use envelope encryption. Candidates miss this limit.

3.

'AWS managed CMKs can be rotated manually.' Wrong. AWS managed keys are managed by AWS; you cannot rotate them. Only customer managed keys can have manual or automatic rotation.

4.

'Deleting a CMK immediately makes data unrecoverable.' Wrong. There is a waiting period (default 30 days) before deletion. Candidates think deletion is instant.

5.

'IAM policies alone can grant access to a CMK.' Wrong. The key policy must allow the root user to delegate via IAM. If the key policy denies IAM, IAM policies are ineffective.

Decision Rule for Exam Questions

When asked about encryption key management, first identify if the question involves controlling keys centrally, integrating with AWS services, or automatic rotation. If yes, choose KMS. If the question involves dedicated hardware, single-tenant HSMs, or regulatory compliance requiring FIPS 140-2 Level 3, choose CloudHSM. If the question is about client-side encryption with SDK, choose AWS Encryption SDK (which uses KMS under the hood). If the question is about managing secrets (passwords, API keys), choose Secrets Manager, not KMS.

Key Takeaways

KMS is a managed service for creating and controlling encryption keys, using FIPS 140-2 validated HSMs.

Customer managed CMKs cost $1/month; AWS managed CMKs are free.

Envelope encryption: use GenerateDataKey to get a data key; encrypt data locally; store encrypted data key.

The Encrypt API has a 1 MB limit; use envelope encryption for larger data.

Key policies are resource-based; IAM policies only work if key policy allows delegation.

Automatic key rotation is available only for symmetric customer managed CMKs (annually).

Deleting a CMK has a waiting period (default 30 days); after that, data is unrecoverable.

KMS integrates with S3 (SSE-KMS), EBS, RDS, Lambda, and many other services.

Use CloudHSM for single-tenant HSMs or FIPS 140-2 Level 3 requirements.

The free tier includes 20,000 KMS requests per month for AWS managed CMKs.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

AWS KMS

Managed service; AWS manages the HSMs

Multi-tenant; keys isolated cryptographically

FIPS 140-2 Level 2 overall (some Level 3)

Pricing: $1/CMK/month + API calls

Integrates with 50+ AWS services

AWS CloudHSM

You manage dedicated HSMs

Single-tenant; full control over hardware

FIPS 140-2 Level 3

Pricing: hourly per HSM (~$1.50/hour)

No native integration; you manage clients

KMS Envelope Encryption

Used for data >1 MB

Generates a data key from CMK

Plaintext key used locally, then discarded

Encrypted data key stored with data

CMK never exposed

Direct Encryption with CMK

Used for data <=1 MB

Encrypts data directly with CMK

CMK handles encryption/decryption

No data key generated

CMK still never exposed

Watch Out for These

Mistake

KMS stores your encryption keys on disk or in a database.

Correct

KMS stores keys in FIPS 140-2 validated hardware security modules (HSMs) that are tamper-resistant. The key material never leaves the HSM in plaintext. Only encrypted data keys are stored outside.

Mistake

You can encrypt any amount of data directly with a CMK.

Correct

The Encrypt API has a 1 MB limit. For larger data, you must use envelope encryption: generate a data key, encrypt your data locally with it, and store the encrypted data key.

Mistake

AWS managed CMKs can be customized or rotated by the customer.

Correct

AWS managed CMKs are created and managed by AWS services. You cannot modify their key policy, enable rotation, or delete them. AWS rotates them approximately every three years.

Mistake

Deleting a CMK immediately makes all encrypted data unrecoverable.

Correct

Deletion has a waiting period (7-30 days, default 30). During this time, the key is in 'Pending Deletion' state and can be canceled. After the waiting period, the key material is destroyed and data becomes unrecoverable.

Mistake

IAM policies alone can grant access to a CMK.

Correct

Access to a CMK requires both a key policy that allows the principal (or allows IAM delegation) and an IAM policy that grants the necessary actions. If the key policy denies IAM, IAM policies are ignored.

Frequently Asked Questions

What is the difference between AWS KMS and AWS CloudHSM?

AWS KMS is a managed service that creates and controls encryption keys for you, using multi-tenant HSMs. It integrates with many AWS services and is pay-per-use. AWS CloudHSM provides dedicated, single-tenant HSMs that you manage yourself. CloudHSM gives you full control over the hardware and supports FIPS 140-2 Level 3, but it is more expensive and requires you to manage the HSM cluster. For most use cases, KMS is sufficient. Choose CloudHSM if you need dedicated hardware or Level 3 compliance.

Can I encrypt data larger than 1 MB with KMS?

Yes, but not directly with the Encrypt API, which has a 1 MB limit. Instead, use envelope encryption: call GenerateDataKey to get a data key, encrypt your data locally with that key, and store the encrypted data key alongside the data. To decrypt, call Decrypt on the encrypted data key to get the plaintext data key, then decrypt your data locally. This is the recommended approach for any data size.

What happens if I delete a CMK?

Deleting a CMK is not immediate. You schedule deletion with a waiting period between 7 and 30 days (default 30). During this time, the key is in 'Pending Deletion' state and cannot be used, but you can cancel deletion. After the waiting period, AWS deletes the key material permanently. Any data encrypted with that key becomes unrecoverable. Always ensure you no longer need the key or have re-encrypted data with another key before deletion.

How does automatic key rotation work in KMS?

Automatic rotation is available only for symmetric customer managed CMKs. When enabled, KMS generates new cryptographic material for the CMK every year. The old material is retained for decryption of data that was encrypted with the previous key. The key ID, alias, and permissions remain unchanged. AWS managed CMKs are rotated approximately every three years automatically. Asymmetric CMKs cannot be automatically rotated.

What is the free tier for KMS?

The KMS free tier includes 20,000 requests per month for AWS managed CMKs (not customer managed). This covers requests to Encrypt, Decrypt, GenerateDataKey, etc., when using AWS managed keys. Customer managed CMKs cost $1 per month each, and API calls for them are not free (except the first 20,000 per month for AWS managed keys). The free tier is per account per region.

Can I use KMS to encrypt data in my own application outside AWS?

Yes. You can use the AWS SDK to call KMS APIs from any application, whether it runs on-premises or in another cloud. However, you must have network access to the KMS endpoint (over the internet or via VPN/Direct Connect). You can generate data keys and encrypt/decrypt data. For client-side encryption, consider using the AWS Encryption SDK, which handles envelope encryption and integrates with KMS.

What is a key policy and how is it different from an IAM policy?

A key policy is a resource-based policy attached directly to a CMK. It defines who can access the key and what actions they can perform. Every CMK must have exactly one key policy. An IAM policy is an identity-based policy attached to a user, group, or role. For an IAM policy to grant access to a CMK, the key policy must explicitly allow the root user to delegate access via IAM (by setting a statement with 'Effect': 'Allow' and 'Principal': {'AWS': 'arn:aws:iam::account-id:root'} and 'Action': 'kms:*' and 'Resource': '*'). If the key policy does not allow IAM, IAM policies are ineffective.

Terms Worth Knowing

Ready to put this to the test?

You've just covered AWS Key Management Service (KMS) — now see how well it sticks with free CLF-C02 practice questions. Full explanations included, no account needed.

Done with this chapter?