> For the complete documentation index, see [llms.txt](https://eric-lo.gitbook.io/lab-serverless-function/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eric-lo.gitbook.io/lab-serverless-function/create-your-first-lambda-function.md).

# Create your first lambda function

We will create a Lambda Function using Lambda console.

1. On the console. Choose **Services** -> **Lambda**

![](https://3703086081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpwAY0pxJ3rOowbOu5E%2Fuploads%2FLZovPPoDcPOQDoyeUnT8%2Fimage.png?alt=media\&token=c1c6a974-a15d-48ed-a279-10bbf11e372a)

&#x20;  2\. In the Lambda console, choose **Create a function**.&#x20;

![](https://3703086081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpwAY0pxJ3rOowbOu5E%2Fuploads%2FPlS7JnfTzYF2Ma3BewNI%2Fimage.png?alt=media\&token=6c06b8f3-4b59-41fe-ac06-925e2445a604)

&#x20;   3\. Choose **Author from Scratch**.&#x20;

![](https://3703086081-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpwAY0pxJ3rOowbOu5E%2F-LpwEMHR2FsthKg-p8NZ%2F-LpwItpbeJdb255GBW5E%2Fimage.png?alt=media\&token=33d81371-5e8a-4973-b06f-49537096f5f1)

&#x20;   4\. For **Name**, type **`sum`**.

&#x20;   5\. Set the **Runtime** to *Python 3.9*

![](https://3703086081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpwAY0pxJ3rOowbOu5E%2Fuploads%2Fljt30LfGaHTG6qTwiBxs%2Flambda-basic-information.png?alt=media\&token=93d505d5-2167-4bcb-add8-be79ece11cc0)

&#x20;   6\. Click **Create function**, and it will redirect to the setup page of Lambda function.

&#x20;   7\. Copy the following Lambda function and paste it into the code editor in the Lambda console.

```
# define function handler with parameters "event" and "context"
# for details, please check https://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html

def sum(event, context): 
    a = float(event["a"])
    b = float(event["b"])
    
    c = a + b
    
    return {
        "c":c
    }
```

&#x20;   8\. In **Runtime settings**, click **Edit** and change the handler to: **lambda\_function.sum**. Remember to click **Save** button to save it.

![](https://3703086081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpwAY0pxJ3rOowbOu5E%2Fuploads%2FhB4GCnR023ar6kRCqxWz%2Fimage.png?alt=media\&token=8836be27-9459-41f7-bef0-c693b1c02dd1)

&#x20;   9\. Now the panel should look like the following fig. Choose **Deploy.**&#x20;

![](https://3703086081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpwAY0pxJ3rOowbOu5E%2Fuploads%2FXBhGaWIAdHyuId7krn7M%2Fimage.png?alt=media\&token=9067fe75-6b5b-4d2e-94a8-ff60c8587cd6)
