AWS Lambda Function Deployment Issues - Possible Causes for Incomplete Execution

Possible Causes for Incomplete Execution of AWS Lambda Function

Prev Question Next Question

Question

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.

Answers

Explanations

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.html
¢ Maximum execution time (timeout) - You pay for the AWS resources that are used to run your Lambda function. To
prevent your Lambda function from running indefinitely, you specify a timeout. When the specified timeout is reached,
AWS Lambda terminates execution of your Lambda function. We recommend you set this value based on your expected
execution time. The default is 3 seconds.

Note

You can invoke a Lambda function synchronously either by calling the Invoke operation or by using an AWS
SDK in your preferred runtime. If you anticipate a long-running Lambda function, your client may time out
before function execution completes. To avoid this, update the client timeout or your SDK configuration. For
more information, see Invoke.

¢ IAM role (execution role) - This is the role that AWS Lambda assumes when it executes the Lambda function on your
behalf. For more information, see AWS Lambda Permissions Model.

The 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.