20240626

AWS Lambda

Serverless Computing Service - Free AWS Lambda - AWS

Compute service that runs your code in response to events and automatically manages the compute resources.

Module 2: Build a Serverless Function

In this module, you will be writing a small piece of code, in Python, JavaScript, or Java, to be used in a later module to add interactivity to your web page. You will use AWS Lambda, a compute service that lets you create serverless functions, eliminating the need for you to manage software and hardware. Instead, applications are broken up into individual functions that can be invoked and scaled individually.

These serverless functions are triggered based on a specific event you will define in the code. … Best of all, you do not have to worry about managing any servers.

OK, so I think AWS Lambda is about creating small functions and attaching them with events.

lambda_function.py from the tutorial

# import the JSON utility package since we will be working with a JSON object
import json

# define the handler function that the Lambda service will use as an entry point
def lambda_handler(event, context):

    # extract values from the event object we got from the Lambda service
    name = event['firstName'] +' '+ event['lastName']
    
    # return a properly formatted JSON object
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda, ' + name)
    }

then,

Module 3: Link a Serverless Function to a Web App

configure a path with the function created to serve API (In this module, it's REST API).

AWS Lambda seems to be helpful when creating a very simple API, such as an experimental one or API with tiny responsiblity, but I'm not sure how it works in real life.


Protein shake 400 Smoothie 300 Sushi bowl 800

Total 1500 kcal


TODO:


index 20240625 20240627