Domain 1 of the DVA-C02 exam requires you to use AWS Key Management Service to create, manage, and rotate encryption keys. Before cloud services existed, developers had to manage encryption keys themselves — a risky, error-prone task that often led to data breaches. AWS KMS solves this by giving you a central, secure place to create, store, and control your encryption keys, so you can protect your data without becoming a cryptography expert.
Jump to a section
A university’s Head of Department is responsible for every confidential document in the faculty — student transcripts, research data, payroll records. She does not hand out the master key to her filing cabinet. Instead, she gives each faculty member a personal, temporary key that only opens the specific drawer they need, and only for a few hours.
If a lecturer needs to update a grade, he requests access through an online form. The Head of Department checks his identity against the staff directory, confirms he is authorised to view that drawer, then creates a short-lived digital copy of the drawer key that expires at 5pm. The lecturer never sees the real master key. If his temporary key is lost, no other cabinet is exposed. When the department is audited, the Head of Department can show a complete log: who asked for which key, when it was granted, and when it expired.
This is exactly how AWS Key Management Service (KMS) works. KMS holds the master key (called a Customer Master Key) and never gives it to anyone. Instead, it generates temporary data keys that applications can use to encrypt or decrypt specific information. The application does not need to store the master key itself, and every request to create or use a key is logged in AWS CloudTrail. The Head of Department is KMS — the central, secure authority that controls key access without ever exposing the master.
Encryption is the process of scrambling data so that only someone with the correct key can read it. Think of it like a locked box. You put your message inside, close the lock, and only the person who has the matching key can open it. AWS Key Management Service (KMS) is a fully managed service that creates and stores those lock-and-key sets for you. It handles all the hard parts — key generation, secure storage, rotation, and access control — so you do not have to write complicated code or manage physical hardware.
When you use KMS, the first thing you do is create a Customer Master Key (CMK). A CMK is the top-level key in KMS. It never leaves the service. You can use this CMK to encrypt and decrypt small amounts of data — up to 64 kilobytes per request — or you can use it to generate other keys called data keys. Data keys are actual cryptographic keys that you can use to encrypt large amounts of data outside of KMS, such as files stored in Amazon S3 or messages placed in Amazon SQS.
Here is the key point: KMS never gives you the CMK itself. When you request a data key, KMS returns two copies — a plaintext copy that you use immediately to encrypt your data, and an encrypted copy that you save alongside your encrypted data. The plaintext copy is used once and then you are told to discard it (your application should never store it). The next time you need to decrypt the data, you send the encrypted copy back to KMS, which decrypts it using the CMK and returns the plaintext key. This process is called envelope encryption.
Why does this matter? Imagine you have a million files in Amazon S3 that you want to encrypt. If you used the CMK directly on each file, you would hit KMS request limits and pay a lot of money. With envelope encryption, you only call KMS once to generate a data key, and then you use that data key locally on all your files. You can even generate a new data key for each file, which is the most secure approach.
KMS also handles key rotation automatically. You can configure your CMK to rotate every year, meaning AWS generates a new cryptographic backing key for the same CMK. Your old data stays encrypted with the old key, but any new encryption uses the new key. KMS keeps the old keys so you can still decrypt older data. This reduces the risk if a key is ever compromised.
Access control is managed through AWS Identity and Access Management (IAM). You create policies that say which users, roles, or services can use which CMKs and under what conditions. For example, you can allow the Lambda service to use a CMK to decrypt environment variables, but only if the request comes from a specific Virtual Private Cloud (VPC). Every API call to KMS is logged in AWS CloudTrail, giving you a full audit trail.
Finally, KMS integrates with many other AWS services like S3, EBS (Elastic Block Store), RDS (Relational Database Service), and Secrets Manager. When you enable encryption on an S3 bucket, you can choose to use a KMS key. The S3 service then calls KMS on your behalf to encrypt and decrypt objects. You do not need to write any code — it is all handled by the service.
What problems does KMS solve that developers used to struggle with? - Key storage: Before KMS, developers had to store encryption keys in their application code or in files on disk. If an attacker got access to the server, they got the keys. With KMS, keys are stored in a hardened service and never exposed to the application. - Key rotation: Manually rotating keys across thousands of files is nearly impossible. KMS automates rotation. - Audit trails: Without KMS, it was hard to know who used which key and when. KMS logs every request. - Compliance: Many regulations (like PCI DSS and HIPAA) require strong key management. KMS is certified to meet these standards.
In summary, KMS is the central keymaster for your AWS account. It does not do the encryption itself for large data — it gives you the tools to do it securely, and it controls access with granular IAM policies. For the DVA-C02 exam, you need to understand how to create CMKs, use envelope encryption, manage key policies, and know which AWS services can use KMS automatically.
Create a Customer Master Key (CMK)
Log into the AWS Management Console, navigate to KMS, and click 'Create key'. Choose a key type (symmetric for most cases), give it an alias like 'production-app-key', and assign a key policy that defines which IAM roles or users can use the key. The CMK is the master key that never leaves KMS.
Configure the key policy
Write a JSON key policy that grants permissions to the AWS account root user and to the specific IAM roles that will use the key (e.g., an application role). Without the correct key policy, even if an IAM user has permissions, they will get an access denied error when calling KMS.
Generate a data key for envelope encryption
Call the KMS API GenerateDataKey, passing the CMK ID. KMS returns two versions of the data key: a plaintext version (to use immediately for encryption) and an encrypted version (to store alongside your data). The plaintext key must be discarded after use.
Encrypt your data using the plaintext data key
Use a local encryption library (like AWS Encryption SDK or OpenSSL) to encrypt your data with the plaintext data key. This can be any size — megabytes or gigabytes. The result is ciphertext that you store alongside the encrypted data key in S3 or on disk.
Decrypt the data when needed
When you need to read the original data, retrieve the encrypted data key from storage. Call the KMS API Decrypt with that encrypted key. KMS returns the plaintext data key. Use it locally to decrypt your ciphertext. Discard the plaintext key immediately after use.
Enable automatic key rotation
In the KMS console, select your CMK and enable automatic rotation. KMS will generate a new cryptographic backing key every year. Old keys are retained so existing encrypted data remains accessible. For custom rotation (e.g., every 90 days), use AWS Lambda to call RotateKeyOnDemand.
Imagine you work for a healthcare start-up called HealthTrack that stores patient medical records in Amazon S3. You need to ensure that all data is encrypted at rest, and you must be able to prove to auditors that only authorised staff can decrypt the data. Here is how you would use AWS KMS in a real project.
Step one: You log into the AWS Management Console and navigate to KMS. You create a Customer Master Key (CMK) with a friendly alias like 'healthtrack-production-key'. You choose the key type — symmetric (one key for both encrypt and decrypt) because that is the most common for S3 encryption. You then define a key policy that grants the IAM role used by your application (say, a Lambda function) permission to use the key. You also add an admin IAM user to manage the key.
Step two: You configure your S3 bucket to use server-side encryption with KMS (SSE-KMS). In the S3 bucket properties, you select 'Encryption' and choose 'AWS KMS' as the encryption type. You enter the ARN (Amazon Resource Name) of your CMK. From this point forward, every object uploaded to the bucket is automatically encrypted by S3 using KMS. You do not need to write any encryption code.
Step three: Your application needs to read patient records. When a user requests a record, your Lambda function reads the encrypted object from S3. S3 automatically calls KMS to decrypt the object using your CMK. The Lambda function must have IAM permissions that allow it to use the kms:Decrypt action on the key. The user never sees the key.
Step four: For more complex needs — like encrypting a large CSV file that you generate on the fly — you might use envelope encryption in your code. Your application calls the KMS API to generate a data key. It receives a plaintext data key and an encrypted data key. It uses the plaintext key to encrypt the CSV file locally, then discards the plaintext key. It stores the encrypted data key alongside the encrypted file in S3. When reading the file, it retrieves the encrypted data key, calls KMS to decrypt it, and then uses the plaintext data key to decrypt the file. This is more flexible than SSE-KMS because you control exactly when and how encryption happens.
Step five: Auditors request a report of all key usage. You enable AWS CloudTrail (which is on by default in most accounts) and look at the KMS events. CloudTrail shows every call to CreateKey, Encrypt, Decrypt, GenerateDataKey, and more. For each event, you can see the IAM principal (who made the call), the source IP address, the key ID, and the timestamp. You export this to an S3 bucket for long-term storage.
What happens if a key is compromised? KMS supports key deletion only after a waiting period (7 to 30 days). During that waiting period, you can cancel the deletion. Once deleted, all data encrypted with that key becomes permanently unrecoverable. So you must be careful. A better practice is to disable the key rather than delete it, so you can still decrypt old data.
In a real team, you would also set up automatic key rotation — either yearly (KMS managed) or on a custom schedule using a scheduled Lambda function. You would monitor CloudWatch metrics for KMS usage, such as number of calls or throttling errors, and set up alarms if usage spikes unexpectedly.
The day-to-day tasks of an IT professional using KMS include: creating and managing CMKs via the console or AWS CLI, writing IAM policies that grant least-privilege access to keys, configuring services (S3, RDS, Lambda) to use KMS encryption, troubleshooting access denied errors (often due to missing kms: permissions), and reviewing CloudTrail logs for security investigations.
The DVA-C02 exam tests your understanding of AWS KMS primarily in the context of encryption at rest and in transit, key management, and integration with other services. Here is exactly what you need to know.
Core concepts you must memorise:
Customer Master Key (CMK): The top-level key in KMS. It can be AWS managed or customer managed. AWS managed keys are created by services like S3 by default. Customer managed keys give you more control (rotation, policies, deletion).
Data key: A symmetric key generated by KMS using a CMK. Used for envelope encryption. You get two copies: plaintext and encrypted.
Envelope encryption: Encrypting a data key with a CMK, then using the data key to encrypt your actual data. This is the recommended approach for large data.
Key policy: A JSON document that defines who can use a CMK and what actions they can perform. It works alongside IAM policies.
Exam traps to watch out for:
The exam loves to ask what happens if you lose a key. The answer is: data encrypted with that key is permanently unrecoverable. There is no AWS support to recover it.
They test whether you can encrypt data larger than 64 KB directly with a CMK. The answer is no — you must use a data key and envelope encryption. The 64 KB limit includes the CMK request.
They ask about key rotation. Customer managed CMKs can have automatic rotation (yearly) enabled. AWS managed CMKs rotate automatically every year, but you cannot change the schedule.
They test the difference between server-side encryption with S3-managed keys (SSE-S3) and KMS (SSE-KMS). SSE-KMS gives you more control and audit trails. SSE-S3 is cheaper but less flexible.
They ask about cross-account key access. To share a CMK between accounts, you must modify the key policy to grant the external account, AND the external account must have an IAM policy allowing access.
They test whether KMS can be used with AWS Lambda environment variables. Yes — Lambda can use a CMK to encrypt environment variables at rest.
Common question patterns:
A scenario question describes an application that encrypts files before uploading to S3. They ask which service to use and how to implement it. The correct answer is usually KMS with envelope encryption.
They describe a compliance requirement to rotate keys every 90 days. The correct approach is to use a customer managed CMK with automated rotation via a scheduled Lambda function (KMS built-in rotation is only yearly).
They describe an audit requirement to track who decrypted objects. The answer is to use AWS CloudTrail to log KMS Decrypt API calls.
They ask which action allows a user to create and manage CMKs. The correct IAM action is kms:CreateKey and kms:PutKeyPolicy.
Key definitions to memorise:
Symmetric key: Same key used for encryption and decryption. Most KMS keys are symmetric.
Asymmetric key: Separate public and private keys. Used for digital signatures or encrypting outside AWS.
Grant: A way to delegate access to a CMK temporarily without changing the key policy.
Ciphertext: The encrypted version of your data.
Plaintext: The original, readable data.
Finally, the exam expects you to know that KMS is a regional service. A CMK created in us-east-1 cannot be used in eu-west-1 unless you use multi-region keys (a newer feature). For the DVA-C02 exam, the default assumption is that keys are regional.
AWS KMS is a managed service that creates and controls encryption keys, not a service that encrypts your data directly.
Envelope encryption uses a Customer Master Key to generate a data key, which then encrypts your actual data — this is the correct way to handle large datasets.
Customer Master Keys never leave KMS; you only receive encrypted copies of data keys that you send back for decryption.
All KMS API calls are logged in AWS CloudTrail, providing a complete audit trail of who used which key and when.
You cannot encrypt more than 64 KB of data directly with a CMK — you must use a data key and envelope encryption for larger payloads.
Customer managed CMKs can be rotated automatically every year, but you can also set custom rotation schedules using AWS Lambda.
Deleting a CMK is permanent and irreversible after a waiting period; always disable a key instead of deleting it if you might need old data.
KMS is a regional service — a key created in one AWS region cannot be used in another without multi-region key support.
Key policies are required to control access to CMKs; IAM policies alone are not sufficient.
AWS services like S3 and RDS can use KMS for encryption with zero code changes using server-side encryption (SSE-KMS).
These come up on the exam all the time. Here's how to tell them apart.
Customer Managed CMK
Created by you, fully customisable
You can enable automatic rotation (yearly)
You can disable or delete the key
AWS Managed CMK
Created automatically by an AWS service (e.g., S3)
Rotation is automatically enabled (yearly)
Cannot be disabled or deleted by you
Symmetric Key
Same key used for encrypt and decrypt
Faster for bulk encryption
Most common for KMS use cases
Asymmetric Key
Has a public key and a private key
Used for digital signatures or encrypting outside AWS
Public key can be shared, private key stays in KMS
Key Policy
Written in JSON, attached directly to the CMK
Defines who can use the key and with what actions
Must always include the account root user for delegation
IAM Policy
Written in JSON, attached to IAM users/roles
Cannot grant access to a CMK unless key policy allows it
Used to further restrict which users in an allowed account can call KMS actions
SSE-S3 (S3-managed keys)
Keys are managed by S3, not customer visible
No additional cost
Least granular control
SSE-KMS (KMS-managed keys)
Keys are managed in AWS KMS, customer visible
Additional KMS costs apply
Granular control with key policies and audit trails
KMS Key
Never leaves AWS KMS
Used to generate data keys
Has a 64 KB encryption limit per call
Data Key
Generated by KMS and can be used outside KMS
Used to encrypt actual data locally
Has no size limit for the data it encrypts
Mistake
KMS encrypts my data for me when I use it directly.
Correct
KMS only manages the keys. For larger data, you must use envelope encryption — KMS generates a data key that you use locally to encrypt, then you discard the plaintext key.
Beginners see 'encryption service' and assume KMS does the encryption like a black box, not understanding the distinction between key management and actual encryption.
Mistake
If I delete a CMK, I can still decrypt my old data using backups of the key material.
Correct
No. When you delete a CMK, AWS permanently deletes the key material after the waiting period. Even if you exported a backup, KMS will not accept it. The data is gone forever.
People confuse CMKs with data keys. They think they can save the key externally and restore it, but KMS is designed so that deletion is irreversible by design for security.
Mistake
IAM policies alone are enough to control access to a KMS key.
Correct
You must use key policies. IAM policies can grant access to the key only if the key policy also allows the account root user to delegate via IAM. Key policies are the primary access control for CMKs.
Many AWS services use only IAM, so beginners assume KMS works the same way. KMS requires key policies and can optionally use IAM — this double-layer confuses people.
Mistake
AWS managed CMKs are the most secure because AWS handles everything.
Correct
Customer managed CMKs give you more control, including custom key policies, key rotation scheduling, and the ability to disable or delete the key. AWS managed keys cannot be customised.
The word 'managed' sounds safer to beginners, but 'customer managed' actually gives you more security control — a counterintuitive naming choice.
Mistake
You can encrypt any amount of data directly with a CMK.
Correct
The maximum plaintext size you can encrypt with a single CMK call is 64 KB (including the request). For larger data, you must use envelope encryption with a data key.
The 64 KB limit is not obvious, and beginners often think an encryption service handles arbitrarily large data.
Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.
No, by default KMS keys are regional. You must create a separate key in each region. For cross-region access, you can use multi-region keys (a newer feature), but for the DVA-C02 exam, assume keys are region-specific.
If you accidentally delete a CMK, all data encrypted with that key becomes permanently unrecoverable after the waiting period (7-30 days). There is no way to recover it. Always disable the key instead of deleting it if you might need old data.
No. KMS has a 64 KB limit per request for direct encryption with a CMK. For larger files, you must use envelope encryption: request a data key from KMS, encrypt the file locally with that data key, and then store the encrypted data key alongside the encrypted file.
AWS managed keys are created automatically by services (like S3) and cannot be customised or deleted. Customer managed keys give you full control: you can set key policies, enable rotation, disable the key, and delete it. Customer managed keys incur an extra monthly cost.
You must modify the key policy to grant the external account permission to use the key. Additionally, the external account must create an IAM policy that allows their users or roles to call KMS actions (like Decrypt) on your key. Both conditions are required.
Yes, you can use KMS from on-premise via the AWS SDK or CLI. You must have internet access or a VPN/VPC connection. KMS also offers a feature called 'KMS key stores' for use with AWS CloudHSM, but that is beyond the DVA-C02 scope.
You've just covered AWS KMS and Encryption Key Management — now see how well it sticks with free DVA-C02 practice questions. Full explanations included, no account needed.
Done with this chapter?