Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

5.2.1. Encryption at Rest: KMS Key Types and Policies

šŸ’” First Principle: Encryption at rest converts data into ciphertext that requires a key to read. The security of encryption at rest depends entirely on the security of the key — so key management is the real challenge. AWS KMS solves key management by keeping keys inside hardware security modules (HSMs) that never expose the raw key material outside the HSM.

KMS Key Types:
Key TypeManaged ByCostUse Case
AWS Owned KeysAWSFreeDefault encryption for many services (S3 SSE-S3, DynamoDB default)
AWS Managed KeysAWS (auto-rotation)FreePer-service keys (aws/s3, aws/rds); less control
Customer Managed Keys (CMK)You~$1/key/monthFull control: custom key policy, rotation control, cross-account use

Key Policies: Unlike IAM policies, KMS key policies are resource-based policies that must explicitly grant access. Without a key policy statement allowing an account, even the root user cannot use the key.

The default key policy for a CMK includes a statement allowing the root account principal — which means IAM policies can then control access. Without this root account statement, you could permanently lose access to the key.

Envelope Encryption: KMS never encrypts your data directly — it uses envelope encryption:

KMS generates a data key (via GenerateDataKey). Your application uses the data key to encrypt the actual data. KMS then encrypts the data key using your CMK. The encrypted data key is stored alongside the encrypted data. To decrypt: call KMS to decrypt the data key, then use the plaintext data key to decrypt the data. The CMK never leaves KMS.

Service-Specific Encryption:
ServiceSSE OptionKey Management
S3SSE-S3AWS managed (free)
S3SSE-KMSAWS or CMK (auditable, CloudTrail logs every decrypt)
S3SSE-CCustomer provides key with each request
EBSDefault encryptionAWS managed or CMK
RDSStorage encryptionAWS managed or CMK (must be set at creation)
DynamoDBDefaultAWS owned (free) or CMK

Key Rotation: Automatic rotation is available for symmetric CMKs. When enabled, KMS rotates the key material annually but keeps the old material to decrypt data encrypted with previous versions. The key ID and ARN stay the same — applications need no changes.

āš ļø Exam Trap: RDS encryption must be enabled at database creation time — you cannot encrypt an existing unencrypted RDS instance. The workaround: create an encrypted snapshot of the unencrypted instance (by copying the snapshot with encryption enabled), then restore from the encrypted snapshot. This creates a new encrypted RDS instance, and you switch your application to the new endpoint.

Reflection Question: An auditor requires that every KMS API call (encrypt, decrypt, generate data key) be logged for compliance. Your S3 buckets use SSE-KMS with a CMK. What is automatically logged, where, and how do you verify this?

Alvin Varughese
Written byAlvin Varughese
Founder•15 professional certifications