A Lambda function is a code and runtime that process events, while a trigger is the AWS service or application that invokes the function. This article starts by explaining what Lambda functions are and how they work. It then goes into detail about the integration of Lambda with other AWS services. The final point explains sources for events in AWS Lambda.
What are Lambda functions and triggers?
Lambda functions are the code that process events. Triggers are the AWS service or application that invokes the function. To illustrate, consider the following scenarios: Configure the event sources to trigger a Lambda function and the Lambda function will fire automatically when events occur. You define event source mapping, which is how you identify what events to track and which Lambda function to invoke. The following are introductory examples of event sources and how the end-to-end experience works. Amazon S3 can publish events of different types, such as PUT, POST, COPY, and DELETE object events on a bucket. Using the bucket notification feature, you can configure an event source mapping that directs Amazon S3 to invoke a Lambda function when a specific type of event occurs. The following is a typical sequence: You configure Amazon S3 to invoke your function as a bucket notification action.
AWS Lambda functions can use other AWS services like Amazon SQS, Amazon S3, and Amazon DynamoDB. These AWS services are integrated with the AWS SDKs (Software Development Kits) for common languages, allowing developers to use their preferred language to write code that interacts with these AWS services. Amazon Web Services offers a lot of useful services, but you can also interact with external web services using Lambda. For example, Python developers can use the Python SDK while Java developers can use the Java SDK. The following is a list of some of the key features of AWS Lambda: Lambda can create new applications and persist state across requests. You can start a lambda function on demand, or configure AWS Lambda to run every minute, every hour or every day, using the AWS Console or by using the AWS CLI.
Lambda supports many AWS services as event sources. When you configure these event sources to trigger a Lambda function, the Lambda function is invoked automatically when events occur. You define event source mapping, which is how you identify what events to track and which Lambda function to invoke. Here is an example of what a Lambda function looks like.
....
import json
def lambda_handler(event, context):
return {
'statusCode': 200,
'body': json.dumps('Hello World')
}
Lambda can help take some of the load off your servers. You may have heard of lambda functions, but been unsure of what they are or how to use them. Lambda is an AWS service that lets you run code without having to provision or manage servers. Functions triggered by events from other AWS services such as S3 and DynamoDB can process data, respond to user actions, or update a database table. In this post we’ve outlined some common lambda application types and use cases. If you’re ready to try lambdas out for yourself, get started with the above Hello World function.