Asterrr's Handbook

Encryption and key management

KMS key types, key policies and grants, cross-account and multi-Region keys, CloudHSM and external key stores, ACM, and S3 encryption options.

Exam tasks: 1.2 (encryption strategies for data at rest and in transit, central key management across accounts), 2.3 (security controls for new solutions)

The decision: who must control the key (AWS, you, or hardware only you can touch), where must it be usable (one account, many accounts, many Regions), and how much operational work will you accept for that control?

Choosing where keys live

KMS key types

AWS owned keyAWS managed keyCustomer managed key
Visible in your accountNoYes, as aws/s3, aws/ebs and so onYes
Who writes the key policyAWSAWS. You can't edit itYou
RotationAWS decidesAutomatic, every yearOptional automatic (you choose the period) or on demand
Cross-account useNoNoYes, through the key policy
CloudTrail usage eventsNoYesYes
Monthly key chargeNoneNoneYes, plus requests
Pick it whenYou just need encryption onYou want an audit trail, not controlSeparation of duties, cross-account, custom rotation, disabling or deleting keys

Other key flavours on a customer managed key:

  • Symmetric (the default and what AWS services use), asymmetric (RSA and ECC for signing or public-key encryption outside AWS) and HMAC.
  • Imported key material (BYOK): you generate the key material and import it. You can set it to expire and delete it immediately, but you're responsible for keeping a copy, and it doesn't rotate automatically.
  • Deleting a key has a waiting period of 7 to 30 days. Disable the key first if you're unsure: disabled keys can be re-enabled, deleted ones can't.

Exam signal

"The security team must be able to revoke access to the data immediately" or "a separate team administers keys" means a customer managed key. You can disable it or change its key policy. AWS managed keys give you neither.

Key policies and grants

  • Every KMS key has exactly one key policy, and it is the primary control. IAM policies only work for a key if its key policy allows it, usually through the default statement that trusts the account root.
  • Split key administrators (manage, rotate, schedule deletion) from key users (Encrypt, Decrypt, GenerateDataKey) in the key policy.
  • Grants give a principal specific operations on one key, can be created and retired through the API, and don't need a key policy edit. AWS services such as EBS, RDS and Secrets Manager use grants behind the scenes. Grants are eventually consistent, so use a grant token for immediate use.
  • Condition keys narrow use: kms:ViaService (only through S3 in a given Region), kms:EncryptionContext:..., kms:CallerAccount.
UseKey policyIAM policyGrant
Long-lived, reviewed accessYesYes, if the key policy delegates to IAMNo
Temporary access for a service or workflowPossible but clumsyNoYes
Access from another accountRequiredRequired in the other accountPossible, once the key policy allows kms:CreateGrant

Cross-account key use

  1. The key policy in account K allows account A (or a role in A) to use the key.
  2. An IAM policy in account A allows its principal the KMS actions on the key's ARN. Aliases don't work across accounts.
  3. Many services resolve the key when they encrypt, so cross-account sharing works best with a single customer managed key per data domain in a central security account.

Sharing the aws/ key

Sharing an encrypted snapshot or bucket with another account fails if it's encrypted with an AWS managed key, because you can't edit that key's policy. Re-encrypt with a customer managed key first, for example by copying the snapshot with a new key.

Multi-Region keys

  • A set of keys in different Regions with the same key ID and key material. Their IDs start with mrk-.
  • Data encrypted in one Region can be decrypted in another without a cross-Region KMS call and without re-encrypting.
  • Each replica is its own resource with its own key policy, grants and aliases. It isn't a global key.
  • Use them for client-side encryption of data that moves between Regions (DynamoDB global tables, S3 replication of client-encrypted objects, signing in several Regions) and for DR. Don't use them by default: a single-Region key keeps data in one Region by design.

Envelope encryption

KMS itself encrypts only small payloads, up to 4 KB. For anything larger:

  • The KMS key never leaves KMS. Only data keys travel, and the stored one is encrypted.
  • This is how S3, EBS and every other integrated service work, and what the AWS Encryption SDK does for you.
  • Pass an encryption context (non-secret key-value pairs) so ciphertext can only be decrypted with the same context, and so CloudTrail records what was decrypted.
4 KB
Largest payload the KMS Encrypt API accepts directly. Use envelope encryption above that.
7–30 days
Waiting period before a scheduled key deletion takes effect.
1 year
Rotation interval for AWS managed keys. Customer managed keys let you choose.
us-east-1
Region where ACM certificates for CloudFront must be.

CloudHSM and external key stores

KMS already uses FIPS-validated HSMs, so "FIPS" alone doesn't demand CloudHSM. Look for these signals:

Requirement in the questionAnswer
Single-tenant HSM, you manage users and keys, AWS has no access to key materialCloudHSM
Standard APIs such as PKCS#11, JCE or CNG, SSL offload, Oracle TDE, or the root key of a PKI you run yourselfCloudHSM
Single-tenant HSM and native encryption in S3, EBS, RDS and other servicesKMS custom key store on CloudHSM
Key material must stay outside AWS, in your own HSM, and you can cut AWS offKMS external key store (XKS)
  • CloudHSM is a cluster you run. Put at least two HSMs in different AZs, since a lost single HSM means lost keys unless you have backups.
  • An external key store adds latency and makes your availability depend on your own HSM and proxy. Only choose it when a regulation requires it.

ACM and TLS certificates

ACM public certificatesAWS Private CA
Trusted byBrowsers and the public internetOnly clients that trust your CA
ValidationDNS (auto-renews while the CNAME stays) or emailNone; you issue from your CA
Deploy toELB, CloudFront, API Gateway and other integrated servicesIntegrated services, plus exportable certs for EC2, containers, IoT and on-premises
Use forPublic websites and APIsInternal services, mTLS, device identity
  • ACM certificates are regional. A certificate for an ALB must be in the ALB's Region.
  • CloudFront (and edge-optimized API Gateway) needs the certificate in us-east-1, whatever Region the origin is in.
  • ACM renews DNS-validated certificates automatically. Email-validated ones need someone to approve each renewal, so prefer DNS validation.
  • By default you can't export the private key of an ACM public certificate. For TLS on EC2 itself, use an exportable certificate or AWS Private CA.

Certificate in the wrong Region

A CloudFront distribution in front of an ALB in eu-west-1 needs two certificates: one in us-east-1 for CloudFront and one in eu-west-1 for the ALB. Answers that "copy" a certificate between Regions are wrong. Request a new one in each Region.

Encryption in transit

PathOptions
Client to load balancerHTTPS listener on ALB, TLS listener on NLB, ACM certificate
Load balancer to targetsRe-encrypt with HTTPS or TLS targets. For end-to-end TLS the load balancer can't inspect, use an NLB TCP listener as passthrough
Client certificate authALB mutual TLS, API Gateway mTLS, or NLB passthrough to targets that verify
Between instancesNitro instance types encrypt traffic automatically between supported instances in the same VPC or peered VPCs
On-premises to AWSSite-to-Site VPN (IPsec). MACsec on dedicated Direct Connect at 10 Gbps and above. Or a VPN over Direct Connect
To S3 and other APIsDeny requests where aws:SecureTransport is false in the bucket policy
DatabasesEnforce TLS with the engine's setting, such as the RDS rds.force_ssl parameter

S3 encryption options

SSE-S3SSE-KMSDSSE-KMSSSE-C
Key managed byS3KMS (AWS managed or customer managed)KMSYou, sent with every request
DefaultYes, for all new objectsOpt inOpt inDisabled by default on new buckets
Audit of key useNoCloudTrail per KMS callCloudTrailNo
Separate permission to decryptNoYes, kms:DecryptYesWhoever holds the key
Cross-account sharingBucket policyBucket policy + key policy (customer managed key)Same as SSE-KMSShare the key out of band
Why pick itSimplest, no costControl, audit, revokeCompliance that demands two layers of encryptionYou must hold keys outside AWS entirely
  • S3 Bucket Keys make S3 derive a bucket-level key from the KMS key, which cuts KMS requests (and their cost and throttling risk) sharply for SSE-KMS. Turn it on for busy buckets.
  • Changing the bucket's default encryption only affects new objects. Re-encrypt existing ones with S3 Batch Operations copy.
  • To enforce a specific key, deny s3:PutObject in the bucket policy unless the encryption headers name that key, or set the default and block other options.
  • Client-side encryption (for example with the Encryption SDK) means S3 only ever sees ciphertext.

Exam signal

"Must audit every use of the key", "must revoke access to all objects at once" or "separation of duties between storage admins and key admins" means SSE-KMS with a customer managed key. "Reduce KMS costs" or "KMS throttling on a busy bucket" means S3 Bucket Keys.

Scenarios

Scenario
A company stores regulated documents in S3 in us-east-1 and replicates them to eu-central-1 for DR. The application encrypts documents client-side with a KMS key before upload. During a regional outage of us-east-1, the DR application in eu-central-1 must decrypt the replicated documents. What should the architect do?
Scenario · choose 2
A media company serves its website through CloudFront with an Application Load Balancer origin in ap-southeast-2. The company wants HTTPS with its own domain name from the viewer to CloudFront and from CloudFront to the ALB, using ACM. Which TWO actions are required?
Scenario
An auditor requires that encryption keys for a payment workload be stored in single-tenant, customer-controlled HSMs to which AWS has no access. The workload stores data in Amazon RDS and Amazon S3, and the team wants to keep using the services' built-in encryption. What should the architect recommend?

Further reading

On this page