Learn how to diagnose and fix common errors that may occur when your AWS Lambda function tries to write data to an Amazon DynamoDB table. Find out the most likely cause of the issue and how to grant the necessary IAM permissions to your Lambda function.
Table of Contents
Question
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?
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.
D. The DynamoDB table is not running in the same Availability Zone as the Lambda function.
Answer
C. The Lambda function does not have IAM permissions to write to DynamoDB.
Explanation
The correct answer is C. The Lambda function does not have IAM permissions to write to DynamoDB.
To write data to an Amazon DynamoDB table from a Lambda function, the function needs to have IAM permissions to perform the PutItem, UpdateItem, or BatchWriteItem API actions on the table. These permissions are set via an IAM role that the function assumes when it is invoked. The role must have a policy that allows the function to access the DynamoDB table.
Option A is incorrect because the Lambda function’s concurrency limit is the number of instances of the function that can run at the same time. If the limit is exceeded, the function invocation will be throttled and return an error. However, this error will occur before the function attempts to write to DynamoDB, not after.
Option B is incorrect because a global secondary index (GSI) is an optional feature of DynamoDB that allows you to create an alternative key for querying the table. A GSI does not affect the ability of a Lambda function to write data to the table.
Option D is incorrect because the DynamoDB table and the Lambda function do not need to run in the same Availability Zone. DynamoDB is a regional service that replicates data across multiple Availability Zones within a region. Lambda functions can access DynamoDB tables in any Availability Zone within the same region.
The latest AWS Certified Developer – Associate DVA-C02 certification actual real practice exam question and answer (Q&A) dumps are available free, which are helpful for you to pass the AWS Certified Developer – Associate DVA-C02 exam and earn AWS Certified Developer – Associate DVA-C02 certification.