# Encryption with AWS KMS

> Encrypt data at rest and in transit using KMS keys, key policies, envelope encryption and rotation. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/cloud-engineer/kms-encryption
Last updated: 2026-11-28

Encrypt data at rest and in transit using KMS keys, key policies, envelope encryption and rotation.

Intermediate · about 4 hours · difficulty 3/5

Learn first: [Policy Evaluation, Conditions and Resource Policies](https://www.internhack.in/roadmaps/tracks/cloud-engineer/iam-policy-evaluation), [S3 Security, Encryption and Lifecycle Rules](https://www.internhack.in/roadmaps/tracks/cloud-engineer/s3-security-lifecycle)

Encryption turns a stolen disk or leaked snapshot into useless bytes. On AWS, most encryption is driven by **AWS Key Management Service (KMS)**. Azure Key Vault and Google Cloud KMS are the equivalents.

### Key types

- **AWS owned keys**: used invisibly by services; you have no control or visibility.
- **AWS managed keys** (aws/s3, aws/ebs): created for you per service, free to store, limited control.
- **Customer managed keys (CMKs)**: you create them, control the key policy, enable rotation, and can disable or schedule deletion. Small monthly fee per key plus request charges.

### How it works

- **Envelope encryption**: KMS generates a data key, the service encrypts your data with it, and stores the data key encrypted under your KMS key. The master key never leaves KMS hardware.
- **Key policies** are resource policies that decide who can use and manage a key. Every key must have one, and IAM policies only work if the key policy allows it.
- **Grants** give temporary, scoped use to services.
- **Automatic rotation** creates new key material yearly (or on your schedule) while old data stays decryptable.

### Where to turn it on

- EBS default encryption per region, S3 default encryption (SSE-KMS with bucket keys), RDS at creation time, DynamoDB, Secrets Manager, CloudTrail logs.
- In transit: TLS everywhere, enforced with bucket policies and ACM certificates.

### Pitfalls

- Scheduling a key for deletion and losing every piece of data encrypted with it. Disable first, wait, then decide.
- Key policies that lock out everyone, including admins.
- Forgetting that encrypted RDS cannot be turned on after creation without a snapshot copy.

You are ready to move on when you can create a customer managed key, restrict it to one role, encrypt an S3 bucket with it, and show the KMS calls in CloudTrail.

## Key concepts

- **AWS owned, AWS managed, customer managed keys**
- **Envelope encryption**
- **Key policies**
- **Key rotation**
- **Default encryption for EBS and S3**
- **Encryption in transit with TLS**
- **CloudHSM**

## Mini project

Create one customer managed key whose key policy allows only a specific role to decrypt. Encrypt an S3 bucket with it, upload a file as that role, then show that your admin user cannot read it without kms:Decrypt. A single key costs a small monthly fee, so schedule its deletion (7-day minimum) right after the lab and delete the bucket.

## Check yourself

Explain envelope encryption in three sentences and why it is used instead of sending all your data to KMS.

## Free resources

- [AWS KMS documentation](https://docs.aws.amazon.com/kms/) (AWS)
- [AWS KMS concepts](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html) (AWS)

Previous: [Auditing with CloudTrail and AWS Config](https://www.internhack.in/roadmaps/tracks/cloud-engineer/cloudtrail-config) · Next: [Secrets Manager and Parameter Store](https://www.internhack.in/roadmaps/tracks/cloud-engineer/secrets-management)

## More in Cloud Security Services

- [Encryption with AWS KMS](https://www.internhack.in/roadmaps/tracks/cloud-engineer/kms-encryption)
- [Secrets Manager and Parameter Store](https://www.internhack.in/roadmaps/tracks/cloud-engineer/secrets-management)
- [GuardDuty, Security Hub and Inspector](https://www.internhack.in/roadmaps/tracks/cloud-engineer/threat-detection)
- [Edge Protection with WAF and Shield](https://www.internhack.in/roadmaps/tracks/cloud-engineer/waf-shield)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cloud Engineer (AWS) Roadmap](https://www.internhack.in/roadmaps/tracks/cloud-engineer)
