You've created a Lambda function with the default settings.
You add code to this function which makes calls to DynamoDB.
You try and deploy the function.
But the function is not completing its execution.
Which of the following might be probable causes for this? Choose 2 answers from the options given below.
Click on the arrows to vote for the correct answer
A. B. C. D.Answer - A and B.
These are given as some of the requirements in the AWS Documentation.
Option C is incorrect since deployment is not needed from the AWS Console.
Option D is incorrect since this is not a pre-requisite for the function to run.
For more information on the AWS Lambda resource model, please refer to the below URL-
https://docs.aws.amazon.com/lambda/latest/dg/resource-model.htmlThe probable causes for the Lambda function not completing its execution after adding code to make calls to DynamoDB are:
A. The IAM Role attached to the function does not have access to DynamoDB: Lambda functions need an IAM role with appropriate permissions to interact with other AWS resources. If the IAM role attached to the function does not have access to DynamoDB, then it will not be able to make calls to it. Therefore, it's important to check whether the IAM role has the necessary permissions for DynamoDB operations.
B. The timeout of the function has been reached: Lambda functions have a default timeout of 3 seconds, after which they will terminate the execution. If the function is making calls to DynamoDB, it may take longer to execute, which can cause the function to timeout before completing the execution. Therefore, it's important to check whether the function's timeout value is sufficient for the expected execution time.
C. You need to deploy the function first: This option is incorrect. Lambda functions can only be invoked after they have been deployed. Therefore, if you are trying to invoke a function that has not been deployed, you will get an error message stating that the function does not exist.
D. You need to create a version for the function first: This option is also incorrect. Creating a version for the function is not necessary for it to be deployed and executed. However, creating a version can be useful for tracking changes made to the function code and its configuration.
To resolve the issue, you should ensure that the IAM role attached to the Lambda function has the necessary permissions for DynamoDB operations. Additionally, you should increase the function's timeout value if it's making calls to DynamoDB, and the expected execution time is longer than the default timeout value.