Invoking Lambda functions
You can invoke Lambda functions directly using the Lambda
console, a function URL HTTP(S) endpoint, the Lambda API,
an Amazon SDK
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. For asynchronous invocation, Lambda handles retries and can send invocation records to a destination.
For another Amazon service to invoke your function directly, you need to create a trigger using the Lambda console. A trigger is a resource you configure to allow another Amazon service to invoke your function when certain events or conditions occur. Your function can have multiple triggers. Each trigger acts as a client invoking your function independently, and each event that Lambda passes to your function has data from only one trigger.
To create a trigger, open the functions page
Each service varies in the options you configure for the trigger and in the structure of the event that the service sends to your Lambda function to invoke it. For a full list of the Amazon services that can invoke your Lambda function by using a trigger, and for more information about configuring triggers for different services, see Using Lambda with other services.
For your Lambda function to process items from a stream or a queue, such as an Amazon Kinesis stream or an Amazon Simple Queue Service (Amazon SQS) queue, you need to create an event source mapping. An event source mapping is a resource in Lambda that reads items from a stream or a queue and creates events containing batches of items to send to your Lambda function. Each event that your function processes can contain hundreds or thousands of items.
You can create an event source mapping for your Lambda function using the Lambda console, the Amazon CLI, the Lambda API, or an Amazon SDK. To create an event source mapping in the Lambda console, follow the instructions to create a trigger, and select one of the Amazon services that support event source mappings as your source. To create an event source mapping using the Amazon CLI, Lambda API, or an Amazon SDK, and to see a list of the Amazon services which event source mappings can be used with, refer to Lambda event source mappings.
Depending on how your function is invoked, scaling behavior and the types of errors that occur can vary. When you invoke a function synchronously, you receive errors in the response and can retry. When you invoke asynchronously, use an event source mapping, or configure another service to invoke your function, the retry requirements and the way that your function scales to handle large numbers of events will vary. For more information, see Error handling and automatic retries in Amazon Lambda.