Skip to Content

Amazon DEA-C01: Why is AWS Lambda function fail to read encrypted S3 object?

If your AWS Lambda function is failing to read an encrypted S3 object, the likely cause is that its execution role lacks the necessary permissions to access the KMS key used to decrypt the object. Learn how to resolve this issue and ensure your Lambda function can successfully retrieve encrypted S3 data.

Table of Contents

Question

A data engineer set up an AWS Lambda function to read an object that is stored in an Amazon S3 bucket. The object is encrypted by an AWS KMS key.

The data engineer configured the Lambda function’s execution role to access the S3 bucket. However, the Lambda function encountered an error and failed to retrieve the content of the object.

What is the likely cause of the error?

A. The data engineer misconfigured the permissions of the S3 bucket. The Lambda function could not access the object.
B. The Lambda function is using an outdated SDK version, which caused the read failure.
C. The S3 bucket is located in a different AWS Region than the Region where the data engineer works. Latency issues caused the Lambda function to encounter an error.
D. The Lambda function’s execution role does not have the necessary permissions to access the KMS key that can decrypt the S3 object.

Answer

D. The Lambda function’s execution role does not have the necessary permissions to access the KMS key that can decrypt the S3 object.

Explanation

For a Lambda function to read an encrypted S3 object, it requires two sets of permissions:

  1. Permissions to access the S3 bucket and read the object. This is typically handled by attaching an IAM policy to the Lambda function’s execution role granting the necessary S3 permissions, such as s3:GetObject.
  2. Permissions to use the KMS key that encrypted the S3 object. The Lambda function needs to be able to call the kms:Decrypt API to decrypt the object data. This requires granting the kms:Decrypt permission on the specific KMS key to the Lambda function’s execution role.

In this scenario, the data engineer already configured the execution role with S3 access permissions. However, they likely missed granting the required KMS permissions. Without the ability to use the KMS key, the Lambda function cannot decrypt and read the contents of the encrypted S3 object, leading to the error.

To resolve this, the data engineer should update the IAM policy attached to the Lambda function’s execution role. They need to add a statement granting the kms:Decrypt permission on the specific KMS key used to encrypt the S3 object. Once the permissions are properly configured, the Lambda function will be able to decrypt the object and successfully retrieve its contents.

Amazon AWS Certified Data Engineer – Associate DEA-C01 certification exam assessment practice question and answer (Q&A) dump including multiple choice questions (MCQ) and objective type questions, with detail explanation and reference available free, helpful to pass the Amazon AWS Certified Data Engineer – Associate DEA-C01 exam and earn Amazon AWS Certified Data Engineer – Associate DEA-C01 certification.