AWS Lambda is a serverless computing service that lets you execute code without worrying about managing servers. Here's an overview of how it works and its benefits:
-
Accessing Lambda:
- Go to the AWS Management Console and search for the
Lambda
service.
- Go to the AWS Management Console and search for the
-
Creating a Function:
- Choose the
Author from scratch
option. - Name your function (e.g.,
mlzoomcamp-test
). - Select the runtime environment (e.g.,
Python 3.9
) and architecture (x86_64
).
- Choose the
-
Understanding Function Parameters:
event
: Contains the input data passed to the function (e.g., a JSON payload).context
: Provides details about the invocation, configuration, and execution environment.
-
Updating the Default Function:
- Edit
lambda_function.py
with custom logic. Example:def lambda_handler(event, context): print("Parameters:", event) # Print input parameters url = event["url"] # Extract URL from input return {"prediction": "clothes"} # Sample response
- Edit
-
Create a Test Event:
- Define a mock input to simulate real-world data.
-
Deploy Changes:
- Save and deploy the function to apply updates.
-
Test Your Function:
- Run the function with the test event to ensure it works as expected.
- Serverless Architecture 🖥️: No need to provision or manage servers.
- Cost-Effective 💰: Pay only for requests and compute time—idle time is free!
- Automatic Scaling 📈: Adjusts automatically based on request volume.
- Ease of Use 🎯: Focus on coding; AWS handles infrastructure.
AWS lambda
was used to automatically redirect users to updated invite links for joining the DataTalks.Club community. This is to avoid expired links on the user side, by using a Lambda function that reads from a config file where invitation links can be update.
Note that AWS Lambda
offers a free tier that includes a certain number of free requests (1 million requests per month), and free compute time (400,000 GB-seconds per month).
Add notes from the video (PRs are welcome)
The notes are written by the community. If you see an error here, please create a PR with a fix. |