KMS Overview
AWS Key Management Service (KMS) is the undisputed core encryption hub across the entire AWS ecosystem. ποΈπ
Whether you are encrypting S3 buckets, EBS volumes, Lambda environment variables, or SSM Parameters, KMS handles the cryptographic key material, authorization logic, and CloudTrail audit logging out of the box.
Key Takeawaysβ
Let's explore the concepts of the core key types, rotation mechanics, regional isolation rules, and custom key policies before we dive into hands-on in the next section.
π Symmetric vs. Asymmetric KMS Keysβ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AWS KMS KEYS β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββ
βΌ βΌ
π SYMMETRIC KEYS π ASYMMETRIC KEYS
β’ Single Secret Key (Encrypt = Decrypt) β’ Public/Private Key Pair
β’ AWS Services ALWAYS use Symmetric Keys β’ Encryption/Decryption OR Sign/Verify
β’ Raw key material NEVER leaves KMS HSMs β’ Public Key can be downloaded outside AWS!
β’ You call API methods (`kms:Encrypt`, `kms:Decrypt`) β’ Private Key NEVER leaves KMS HSMs
- Symmetric Keys π: Uses a single key for both encryption and decryption. Every AWS service integrated with KMS requires a symmetric key. You never see or download the raw key material; you only interact with it via KMS API calls.
- Asymmetric Keys π: Consists of a Public Key (which can be exported outside AWS for external users to encrypt payloads) and a Private Key (stored safely inside KMS HSMs to perform decryption inside your cloud account).
π·οΈ The KMS Key Hierarchy & Pricing Matrixβ
| Key Category | Created / Owned By | Visibility | Cost | Rotation Strategy |
|---|---|---|---|---|
| AWS Owned Keys | AWS Services (e.g., S3, DynamoDB) | Invisible in your console | FREE | Managed automatically by the AWS Service. |
| AWS Managed Keys | Created in your account by AWS (aws/s3, aws/ebs) | Visible in KMS console | FREE (No monthly fee) | Automatically rotated every 1 year (365 days). |
| Customer Managed Keys (CMK) | Created & managed by YOU | Full visibility & control | $1/month + API usage fees | Optional auto-rotation (every 90β2560 days, default 1 year) or on-demand. |
| Imported Keys | Created in your On-Premise HSM | Managed by YOU | $1/month + API usage fees | Manual rotation ONLY (using aliases). |
π Regional Isolation & The Cross-Account Snapshot Copy Patternβ
KMS Keys are strictly bound to a single AWS Region! You cannot use a KMS Key in us-east-1 to directly encrypt or decrypt data residing in ap-southeast-2.
π Pattern A: Cross-Region Resource Migrationβ
To copy an encrypted resource (like an EBS Snapshot or RDS Snapshot) to a new region, you must execute a Re-Encryption Handshake during the copy process:
- Snapshot is encrypted in Region A using KMS Key A.
- Initiating a Region Copy operation re-encrypts the snapshot data using KMS Key B in Region B.
- The new snapshot in Region B can now be restored as a volume!

π€ Pattern B: Cross-Account Resource Sharingβ
To share an encrypted snapshot with another AWS account:
- You CANNOT share resources encrypted with AWS Managed Keys (
aws/ebs) across accounts! You MUST use a Customer Managed Key (CMK). - Update the CMK's Key Policy in Account A to grant
kms:Decrypt,kms:DescribeKey, andkms:CreateGrantpermissions to Account B.

- Share the snapshot with Account B.
- Account B copies the snapshot into its own account, re-encrypting it using Account B's local CMK!
π KMS Key Policies: The Ultimate Access Controlβ
Unlike standard IAM policies, IAM policies ALONE are not enough to access a KMS key! You must explicitly authorize access inside the KMS Key Policy.
π DEFAULT KEY POLICY (Delegates to IAM):
Allows root account principal βββΊ Enables IAM policies attached to users/roles to grant access.
π CUSTOM KEY POLICY (Explicit Control & Cross-Account):
Directly dictates which users, roles, or EXTERNAL ACCOUNTS can use or administer the key!
{
"Sid": "Allow Cross-Account Use of the Key",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::999999999999:root"
},
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": "*"
}
Exam Tipsβ
- The Cross-Account Snapshot Sharing Trap π¨: If a scenario asks why an engineer cannot share an encrypted EBS snapshot with a secondary AWS accountβcheck if the snapshot is encrypted with an AWS Managed Key (
aws/ebs). AWS Managed Keys CANNOT be shared cross-account! The snapshot must be re-encrypted using a Customer Managed Key with an updated Key Policy. - The CloudTrail Audit Requirement: If a question asks how to track every single user, role, or service attempting to encrypt or decrypt data using KMS keysβtarget Amazon CloudTrail integration! Every KMS API call (
kms:GenerateDataKey,kms:Decrypt) is logged as a CloudTrail event. - Cross-Region Snapshot Copying: If a prompt asks how to move an encrypted RDS database backup to another AWS regionβselect the option that copies the snapshot to the target region while specifying a target region KMS key for re-encryption.
Practice Testβ
Question 1: A development team has created a new IAM user that has s3:putObject permission to write to an S3 bucket. This S3 bucket uses server-side encryption with AWS KMS managed keys (SSE-KMS) as the default encryption. Using the access key ID and the secret access key of the IAM user, the application received an access denied error when calling the PutObject API.
As a Developer Associate, how would you resolve this issue?
- Correct the policy of the IAM user to allow the
kms:GenerateDataKeyaction - Correct the policy of the IAM user to allow the
s3:Encryptaction - Correct the ACL of the S3 bucket to allow the IAM user to upload encrypted objects
- Correct the bucket policy of the S3 bucket to allow the IAM user to upload encrypted objects
Correct Answer
- Correct the policy of the IAM user to allow the
kms:GenerateDataKeyaction-
Explanation: Correct the policy of the IAM user to allow the
kms:GenerateDataKeyaction - You can protect data at rest in Amazon S3 by using three different modes of server-side encryption: SSE-S3, SSE-C, or SSE-KMS. SSE-KMS requires that AWS manage the data key but you manage the customer master key (CMK) in AWS KMS. You can choose a customer managed CMK or the AWS managed CMK for Amazon S3 in your account. If you choose to encrypt your data using the standard features, AWS KMS and Amazon S3 perform the following actions:- Amazon S3 requests a plaintext data key and a copy of the key encrypted under the specified CMK.
- AWS KMS generates a data key, encrypts it under the CMK, and sends both the plaintext data key and the encrypted data key to Amazon S3.
- Amazon S3 encrypts the data using the data key and removes the plaintext key from memory as soon as possible after use.
- Amazon S3 stores the encrypted data key as metadata with the encrypted data.
The error message indicates that your IAM user or role needs permission for the
kms:GenerateDataKeyaction. This permission is required for buckets that use default encryption with a custom AWS KMS key.In the JSON policy documents, look for policies related to AWS KMS access. Review statements with
"Effect": "Allow"to check if the user or role has permissions for thekms:GenerateDataKeyaction on the bucket's AWS KMS key. If this permission is missing, then add the permission to the appropriate policy.In the JSON policy documents, look for statements with
"Effect": "Deny". Then, confirm that those statements don't deny thes3:PutObjectaction on the bucket. The statements must also not deny the IAM user or role access to thekms:GenerateDataKeyaction on the key used to encrypt the bucket. Additionally, make sure the necessary KMS and S3 permissions are not restricted using a VPC endpoint policy, service control policy, permissions boundary, or session policy.
-
Question 2: A financial services company wants to ensure that the customer data is always kept encrypted on Amazon S3 but wants an AWS managed solution that allows full control to create, rotate and remove the encryption keys.
As a Developer Associate, which of the following would you recommend to address the given use-case?
- Server-Side Encryption with Customer-Provided Keys (SSE-C)
- Server-Side Encryption with Secrets Manager
- Server-Side Encryption with Customer Master Keys (CMKs) Stored in AWS Key Management Service (SSE-KMS)
- Server-Side Encryption with Amazon S3-Managed Keys (SSE-S3)
Correct Answer
- Server-Side Encryption with Customer-Provided Keys (SSE-C)
- Explanation: With Server-Side Encryption with Customer-Provided Keys (SSE-C), you will need to create the encryption keys as well as manage the corresponding process to rotate and remove the encryption keys. Amazon S3 manages the data encryption, as it writes to disks, as well as the data decryption when you access your objects. So this option is incorrect for the given use-case.-
- Server-Side Encryption with Secrets Manager
- Explanation: AWS Secrets Manager helps you protect secrets needed to access your applications, services, and IT resources. The service enables you to easily rotate, manage, and retrieve database credentials, API keys, and other secrets throughout their lifecycle. You cannot combine Server-Side Encryption with Secrets Manager to create, rotate, or disable the encryption keys.-
- Server-Side Encryption with Customer Master Keys (CMKs) Stored in AWS Key Management Service (SSE-KMS)
- Explanation: You have the following options for protecting data at rest in Amazon S3:
- Server-Side Encryption β Request Amazon S3 to encrypt your object before saving it on disks in its data centers and then decrypt it when you download the objects.
- Client-Side Encryption β Encrypt data client-side and upload the encrypted data to Amazon S3. In this case, you manage the encryption process, the encryption keys, and related tools.
- When you use server-side encryption with AWS KMS (SSE-KMS), you can use the default AWS managed CMK, or you can specify a customer-managed CMK that you have already created.
- Creating your own customer-managed CMK gives you more flexibility and control over the CMK. For example, you can create, rotate, and disable customer-managed CMKs. You can also define access controls and audit the customer-managed CMKs that you use to protect your data.

- Explanation: You have the following options for protecting data at rest in Amazon S3:
- Server-Side Encryption with Amazon S3-Managed Keys (SSE-S3)
- Explanation: When you use Server-Side Encryption with Amazon S3-Managed Keys (SSE-S3), each object is encrypted with a unique key. As an additional safeguard, AWS encrypts the key itself with a master key that it regularly rotates. So this option is incorrect for the given use-case.