A developer is deploying a microservice on Amazon ECS that processes sensitive configurations. A configuration file of size is encrypted client-side using envelope encryption with an AWS KMS customer managed key (CMK). During deployment, the application container fails to start because it cannot decrypt the configuration file.
The current configuration is as follows:
- The `kms:Decrypt` permission is granted to the ECS task execution role.
- The application code attempts to decrypt the entire configuration file by calling the `kms:Decrypt` API directly with the encrypted file content.
Which combination of actions will resolve the decryption failure and allow the application to start up successfully?
- Associate the `kms:Decrypt` permission with the ECS Task Role instead of the ECS Task Execution Role. Update the application code to pass only the encrypted data key to the `kms:Decrypt` API to retrieve the plaintext data key, then decrypt the configuration file locally using the plaintext data key.Answer
- BAssociate the `kms:Decrypt` permission with the ECS Task Role instead of the ECS Task Execution Role. Update the application code to pass the entire encrypted configuration file to the `kms:Decrypt` API, and ensure that the payload size does not exceed the payload limit of the API.
- CRetain the `kms:Decrypt` permission on the ECS Task Execution Role. Update the application code to call the `kms:Decrypt` API with the encrypted data key to retrieve the plaintext data key, and then decrypt the configuration file locally using the plaintext data key.
- DRetain the `kms:Decrypt` permission on the ECS Task Execution Role. Configure the application to use the Systems Manager Parameter Store to retrieve the plaintext KMS customer managed key at runtime, and decrypt the configuration file locally.
Answer
Associate the kms:Decrypt permission with the ECS Task Role instead of the ECS Task Execution Role. Update the application code to pass only the encrypted data key to the kms:Decrypt API to retrieve the plaintext data key, then decrypt the configuration file locally using the plaintext data key.
The correct answer correctly identifies that application code running inside an ECS container must use the ECS Task Role for runtime authorization to call KMS APIs. Additionally, in envelope encryption, the actual payload is encrypted locally with a data key, and only the encrypted data key is sent to AWS KMS for decryption. This bypasses the payload size limit of the `kms:Decrypt` API.
Step-by-Step Solution
Key Concept
AWS KMS Envelope Decryption and ECS IAM Roles
Estimated Time:2m 0s