A developer is implementing client-side envelope encryption for a microservice that processes sensitive payload objects larger than before storing them in an Amazon DynamoDB table. The developer needs to minimize latency, avoid KMS cryptographic limits, and ensure secure key storage.
Which of the following workflows is the correct method to encrypt and store the payloads?
- ACall `Encrypt` using the Customer Managed Key (CMK) to encrypt each payload directly, and then call `GenerateDataKeyWithoutPlaintext` to generate a secondary local data key to encrypt the metadata before storing both payloads in DynamoDB.
- Call `GenerateDataKey` using the Customer Managed Key (CMK) to obtain a plaintext data key and a ciphertext data key. Encrypt the payload locally using the plaintext data key, immediately delete the plaintext data key from memory, and store the ciphertext data key alongside the encrypted payload in DynamoDB.Answer
- CCall `GenerateDataKey` to obtain a data key, encrypt the payload locally, and store the plaintext data key as a secure configuration in Systems Manager Parameter Store with automatic rotation enabled to decrypt future payloads.
- DCall `GenerateDataKey` using the Customer Managed Key (CMK) to get the plaintext key, encrypt the payload, and then update the IAM Trust Policy of the microservice's execution role to allow the DynamoDB service principal to decrypt the data key directly.
Answer
Call the `GenerateDataKey` API to obtain a plaintext and ciphertext data key, encrypt the payload locally, delete the plaintext key from memory, and store the ciphertext data key with the encrypted payload in DynamoDB.
The correct workflow for client-side envelope encryption involves calling the `GenerateDataKey` API to obtain both a plaintext and a ciphertext version of a unique data key. The plaintext key is used to perform the resource-intensive encryption locally, keeping payload transit off the network and avoiding KMS API rate limits or payload size limits. The plaintext key is then deleted from memory, and the encrypted (ciphertext) data key is stored alongside the encrypted data.
Step-by-Step Solution
Key Concept
AWS KMS Envelope Encryption
Estimated Time:2m 30s