Creating a Lambda Function
- Console: Choose "Create Function," configure settings (name, runtime, execution role).
- CLI: Use
aws lambda create-function with necessary parameters like -function-name, -runtime, and -role.
- CDK: Define Lambda function in your infrastructure code using a supported language (e.g., Node.js, Python).
Invoking a Lambda Function
- Manually (Console): Trigger the function with a test event.
- CLI: Use
aws lambda invoke with the payload in JSON format.
- SDKs: Invoke using AWS SDKs (Node.js, Python, etc.) with
lambda.invoke.
- Event-based: Lambda functions can be triggered by other AWS services like API Gateway, S3, or CloudWatch Events.
Invocation Types
- Synchronous: Lambda waits for the result and returns it to the invoker (e.g., API Gateway).
- Asynchronous: Lambda queues the event for processing later (e.g., SNS, SQS).
- Event Source Mapping: Automatically invokes Lambda when new events are available in the source, like an SQS message.