A developer is implementing client-side envelope encryption to secure proprietary application log files, each approximately in size, before archiving them to an Amazon S3 bucket. The developer wants to minimize both network latency and KMS API costs while ensuring the application principal adheres to the principle of least privilege. Which two actions must the developer perform to successfully implement the encryption phase of this workflow?
- Grant the application's IAM role permissions for the `kms:GenerateDataKey` action, but do not grant permissions for the `kms:Encrypt` action.Answer
- Call the `GenerateDataKey` API operation, encrypt the log file client-side using the returned plaintext data key, and then save both the encrypted log file and the encrypted data key to Amazon S3.Answer
- CCall the `GenerateDataKeyWithoutPlaintext` API operation to retrieve the encrypted data key, use it directly to encrypt the log file, and discard the key.
- DGrant the application's IAM role permissions for the `kms:Encrypt` action, and call the `Encrypt` API operation for each log file to secure the payload before uploading to S3.
- EStore the plaintext data key in AWS Systems Manager Parameter Store as a SecureString parameter, using the log file's S3 object key as the parameter name.
Answer
Grant the application's IAM role permissions for the `kms:GenerateDataKey` action (excluding `kms:Encrypt`) and call the `GenerateDataKey` API operation, using the returned plaintext data key to encrypt the log file locally before saving the encrypted log and the encrypted data key to Amazon S3.
The correct configuration requires calling the `GenerateDataKey` API operation, which returns both the plaintext data key (used for local symmetric encryption of the file) and the ciphertext data key (stored with the encrypted file in S3). Because the encryption is performed locally by the application rather than by the KMS service, the application's IAM role only requires `kms:GenerateDataKey` permission and does not need `kms:Encrypt` permission.
Step-by-Step Solution
Key Concept
AWS KMS client-side envelope encryption workflow and IAM privilege separation