How do I troubleshoot Lambda synchronous invocation issues?

3 minute read
-1

I’ve set up an AWS Lambda function to invoke synchronously but the destination isn’t initiating. How do I fix this issue? When I invoke a Lambda function through the Lambda console does it get invoked synchronously or asynchronously? -or- Why isn't my Lambda function retrying after I set it to retry one or two more times?

Resolution

When you synchronously invoke a Lambda function and it fails, the following are possible causes:

  • Lambda doesn’t have permission to perform the actions included in the code.
  • The AWS service that invokes the Lambda function doesn’t have sufficient permissions.
  • Lambda is invoked asynchronously.
  • Lambda supports destinations only for asynchronous invocations and stream invocations, and not for synchronous invocations.

Follow these steps to troubleshoot synchronous invocation issues:

1.    Determine how the Lambda function is invoked. Is the function invoked using AWS CLI? Is the function invoked through an AWS service?

2.    Check whether the AWS service invokes the Lambda function synchronously or asynchronously.

3.    Invoke the Lambda function synchronously by using the following command:

aws lambda invoke --function-name my-function --cli-binary-format raw-in-base64-out --payload '{ "key": "value" }' response.json

See if a 200 status code is reported or if the command returns an error.

4.    Remember that Lambda function retry behavior is controlled by the client in synchronous invocations. The Retry attempts configuration from the AWS Lambda console is limited to asynchronous invocations. Make sure that the client retries the requests rather than checking the Lambda logs.

5.    Remember that a Lambda function invoked in the Lambda console is always a synchronous invocation.

6.    Synchronous invocation retry behavior varies between AWS services, based on each service's event source mapping.

For more information, see Event-driven invocation.

7.    Make sure that the Lambda function's code is idempotent and can handle the same messages multiple times.

8.    Identify and resolve any errors that your Lambda function returns.

For more information, see How do I troubleshoot Lambda function failures?

9.    If you still can’t resolve the issue, open a case with AWS Support. Provide the following information in the case:

  • The Lambda function ARN.
  • The workflow on the Lambda function setup with all included services.
  • Details about whether the issue is intermittent or continuous.
  • Complete CloudWatch logs in .txt format from when the issue occurred. These CloudWatch logs are used to identify Lambda function errors that include timeout issues, init durations, and permissions issues.
  • The exact timestamp of the issue with the timezone or timestamp in UTC.

Note: AWS Support representatives don’t have access to customer CloudWatch logs due to security and privacy reasons.


Related information

Comparing Lambda invocation modes

Invoking Lambda functions

Introducing AWS Lambda Destinations

AWS OFFICIAL
AWS OFFICIALUpdated a year ago