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 key | AWS managed key | Customer managed key | |
|---|---|---|---|
| Visible in your account | No | Yes, as aws/s3, aws/ebs and so on | Yes |
| Who writes the key policy | AWS | AWS. You can't edit it | You |
| Rotation | AWS decides | Automatic, every year | Optional automatic (you choose the period) or on demand |
| Cross-account use | No | No | Yes, through the key policy |
| CloudTrail usage events | No | Yes | Yes |
| Monthly key charge | None | None | Yes, plus requests |
| Pick it when | You just need encryption on | You want an audit trail, not control | Separation 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.
| Use | Key policy | IAM policy | Grant |
|---|---|---|---|
| Long-lived, reviewed access | Yes | Yes, if the key policy delegates to IAM | No |
| Temporary access for a service or workflow | Possible but clumsy | No | Yes |
| Access from another account | Required | Required in the other account | Possible, once the key policy allows kms:CreateGrant |
Cross-account key use
- The key policy in account K allows account A (or a role in A) to use the key.
- An IAM policy in account A allows its principal the KMS actions on the key's ARN. Aliases don't work across accounts.
- 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.
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 question | Answer |
|---|---|
| Single-tenant HSM, you manage users and keys, AWS has no access to key material | CloudHSM |
| Standard APIs such as PKCS#11, JCE or CNG, SSL offload, Oracle TDE, or the root key of a PKI you run yourself | CloudHSM |
| Single-tenant HSM and native encryption in S3, EBS, RDS and other services | KMS custom key store on CloudHSM |
| Key material must stay outside AWS, in your own HSM, and you can cut AWS off | KMS 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 certificates | AWS Private CA | |
|---|---|---|
| Trusted by | Browsers and the public internet | Only clients that trust your CA |
| Validation | DNS (auto-renews while the CNAME stays) or email | None; you issue from your CA |
| Deploy to | ELB, CloudFront, API Gateway and other integrated services | Integrated services, plus exportable certs for EC2, containers, IoT and on-premises |
| Use for | Public websites and APIs | Internal 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
| Path | Options |
|---|---|
| Client to load balancer | HTTPS listener on ALB, TLS listener on NLB, ACM certificate |
| Load balancer to targets | Re-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 auth | ALB mutual TLS, API Gateway mTLS, or NLB passthrough to targets that verify |
| Between instances | Nitro instance types encrypt traffic automatically between supported instances in the same VPC or peered VPCs |
| On-premises to AWS | Site-to-Site VPN (IPsec). MACsec on dedicated Direct Connect at 10 Gbps and above. Or a VPN over Direct Connect |
| To S3 and other APIs | Deny requests where aws:SecureTransport is false in the bucket policy |
| Databases | Enforce TLS with the engine's setting, such as the RDS rds.force_ssl parameter |
S3 encryption options
| SSE-S3 | SSE-KMS | DSSE-KMS | SSE-C | |
|---|---|---|---|---|
| Key managed by | S3 | KMS (AWS managed or customer managed) | KMS | You, sent with every request |
| Default | Yes, for all new objects | Opt in | Opt in | Disabled by default on new buckets |
| Audit of key use | No | CloudTrail per KMS call | CloudTrail | No |
| Separate permission to decrypt | No | Yes, kms:Decrypt | Yes | Whoever holds the key |
| Cross-account sharing | Bucket policy | Bucket policy + key policy (customer managed key) | Same as SSE-KMS | Share the key out of band |
| Why pick it | Simplest, no cost | Control, audit, revoke | Compliance that demands two layers of encryption | You 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:PutObjectin 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
Multi-Region keys share key material, so ciphertext created with the us-east-1 key decrypts with the eu-central-1 replica, with no call to the failed Region. Granting access to the us-east-1 key still needs us-east-1 to be up. SSE-S3 doesn't apply to data the app encrypted itself, and KMS never lets you export key material.
CloudFront only uses ACM certificates from us-east-1, and an ALB only uses certificates from its own Region, so the company needs one of each. A single certificate can't be attached in both Regions. The targets don't need a certificate for this requirement, and a private CA certificate wouldn't be trusted by viewers' browsers.
A custom key store keeps key material in a CloudHSM cluster the customer controls, while RDS and S3 keep using their normal KMS integration. Standard KMS keys, managed or customer managed, live in multi-tenant KMS HSMs. SSE-C doesn't work with RDS, and Secrets Manager isn't an HSM.
Further reading
Workforce federation
IAM Identity Center, IAM SAML federation, the three AWS Directory Service options, AD trusts, and ABAC with session tags.
Central security and logging
Collecting audit logs, findings and compliance data from every account and Region into dedicated security accounts, and making the logs tamper-proof.