Understanding Lambda function invocation methods - Amazon Lambda
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Understanding Lambda function invocation methods

After you deploy your Lambda function, you can invoke it in several ways:

  • The Lambda console – Use the Lambda console to quickly create a test event to invoke your function.

  • The Amazon SDK – Use the Amazon SDK to programmatically invoke your function.

  • The Invoke API – Use the Lambda Invoke API to directly invoke your function.

  • The Amazon Command Line Interface (Amazon CLI) – Use the aws lambda invoke Amazon CLI command to directly invoke your function from the command line.

  • A function URL HTTP(S) endpoint – Use function URLs to create a dedicated HTTP(S) endpoint that you can use to invoke your function.

All of these methods are direct ways to invoke your function. In Lambda, a common use case is to invoke your function based on an event that occurs elsewhere in your application. Some services can invoke a Lambda function with each new event. This is called a trigger. For stream and queue-based services, Lambda invokes the function with batches of records. This is called an event source mapping.

When you invoke a function, you can choose to invoke it synchronously or asynchronously. With synchronous invocation, you wait for the function to process the event and return a response. With asynchronous invocation, Lambda queues the event for processing and returns a response immediately. The InvocationType request parameter in the Invoke API determines how Lambda invokes your function. A value of RequestResponse indicates synchronous invocation, and a value of Event indicates asynchronous invocation.

To invoke your function over IPv6, use Lambda's public dual-stack endpoints. Dual-stack endpoints support both IPv4 and IPv6. Lambda dual-stack endpoints use the following syntax:

protocol://lambda.us-east-1.api.aws

You can also use Lambda function URLs to invoke functions over IPv6. Function URL endpoints have the following format:

https://url-id.lambda-url.us-east-1.on.aws

If the function invocation results in an error, for synchronous invocations, view the error message in the response and retry the invocation manually. For asynchronous invocations, Lambda handles retries automatically and can send invocation records to a destination.