DVA-C02 practice question 21 of 35

A developer has created an AWS Lambda function that is written in Python. The Lambda function reads data from objects in Amazon S3 and writes data to an Amazon DynamoDB table. The function is successfully invoked from an S3 event notification when an object is created. However, the function fails when it attempts to write to the DynamoDB table. What is the MOST likely cause of this issue?

Full set: 598 questions

Domain Development with AWS Services

Answer options
A: The Lambda function's concurrency limit has been exceeded.
B: DynamoDB table requires a global secondary index (GSI) to support writes.
C: The Lambda function does not have IAM permissions to write to DynamoDB. Correct answer
D: The DynamoDB table is not running in the same Availability Zone as the Lambda function.
Correct Answer:
C. The Lambda function does not have IAM permissions to write to DynamoDB.
Explanation

AWS Lambda functions use an IAM execution role to get the necessary permissions to interact with other AWS services. The scenario states the function is invoked successfully by an S3 event but fails when writing to DynamoDB. This indicates the execution role has permissions for invocation by S3 but lacks the required permissions (e.g., dynamodb:PutItem, dynamodb:UpdateItem) to perform write operations on the target DynamoDB table. This is a common configuration error and the most direct cause for the described failure.

Why Incorrect

A. A concurrency limit being exceeded would typically result in a ThrottlingException, preventing the function from being invoked, rather than a failure during the execution of the function's code.
B. Global secondary indexes (GSIs) are used to speed up queries on non-key attributes. They are not a requirement for performing basic write operations like PutItem on a DynamoDB table.
D. Both AWS Lambda and Amazon DynamoDB are regional services. AWS manages their operation across multiple Availability Zones within a region for high availability, so an AZ mismatch is not a possible cause.

References

1. AWS Lambda Developer Guide

"AWS Lambda execution role": This document explains that a Lambda function's execution role grants it permission to access other AWS services and resources. It states

"You grant your function permissions to use other AWS services by attaching policies to its execution role." This supports the conclusion that missing permissions in the role is the cause.

2. Amazon DynamoDB Developer Guide

"Identity and Access Management for Amazon DynamoDB"

Section: "Actions": This section lists the specific API actions that can be permitted or denied for DynamoDB

such as dynamodb:PutItem. The failure to write implies this action is not allowed by the Lambda function's IAM policy.

3. AWS Lambda Developer Guide

"Managing concurrency for a Lambda function": This guide details that when invocations exceed the concurrency limit

Lambda throttles the requests. This confirms that a concurrency issue would manifest as an invocation failure

not a runtime error during a specific API call within the code.

4. Amazon DynamoDB Developer Guide

"Amazon DynamoDB core components"

Section: "Regions and Availability Zones": This document clarifies

"DynamoDB is available in multiple AWS Regions around the world. Each Region is independent and isolated... Data is replicated across multiple Availability Zones in each Region." This invalidates the premise of an AZ mismatch.

Scroll to Top