# Amazon Lambda:  Create Lambda Function

### Objective <a href="#toc94634309" id="toc94634309"></a>

This guide will help you to quickly connect to Amazon Lambda and create a sample Lambda functions as a prerequisite to integrate Amazon Lambda to iX Hello.

### Pre-requisites <a href="#toc94634310" id="toc94634310"></a>

* **An active AWS Account**

You should have an active AWS Account. If you do not have it, you can create an AWS account at <https://portal.aws.amazon.com/billing/signup#/start>

*AWS Accounts Include 12 Months of Free Tier Access*

### Steps <a href="#toc94634311" id="toc94634311"></a>

To proceed with these steps, you should have all the pre-requisites satisfied. If you are missing something, please go back and make sure you satisfy all of them.

Once done, you can now proceed with the following process.

### Create Lambda Function <a href="#toc94634312" id="toc94634312"></a>

1. Login to your AWS console in [https://console.aws.amazon.com](https://console.aws.amazon.com/) using your AWS credentials.
2. Search for Lambda in the search bar and click on Lambda Service.

!\[Graphical user interface, application

Description automatically generated]\(<https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2F7j1b7VlmYg26Mr252Zug%2F0?alt=media>)

3. You will be directed to the AWS Lambda dashboard.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FP1BwzAIzMs8uRBiNPfTU%2Fimage.png?alt=media&#x26;token=e910e334-f65a-4f64-978d-eeaabc216619" alt=""><figcaption></figcaption></figure>

4. Click on Create Function. Fill in the following details:

| Select Author from Scratch   |
| ---------------------------- |
| Function Name: ContactFinder |
| Runtime: Python 3.9          |
| Architecture: x86\_64        |
| Click on Create Function     |

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2Fdr99Y3kensXGKJ3YrjDn%2Fimage.png?alt=media&#x26;token=8bfafccb-8afe-43cd-b5d7-49503a372e22" alt=""><figcaption></figcaption></figure>

5. You will be now directed to the following screen to change the code and configuration of the Lambda function.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FhiWDKHVf1B3N41DC6JBz%2Fimage.png?alt=media&#x26;token=01e121e8-85cc-46a9-adc0-27846e35bb9c" alt=""><figcaption></figcaption></figure>

6. Now replace the text in the text editor with following value:
7. The resulting screen will be something like this.

```
import json
 
def lambda_handler(event, context):
    # TODO implement
    if(event["name"] == "kiran"):
        return { 
            'name': 'Kiran', 
            'phone': '9429020115', 
            'country': 'India' 
        }
    if(event["name"] == "rose"):
        return { 
            'name': 'Rose', 
            'phone': '(512) 757-6001', 
            'country': 'USA' 
        }
    if(event["name"] == "sean"):
        return { 
            'name': 'Sean', 
            'phone': '(512) 757-6002', 
            'country': 'UK' 
        }
    if(event["name"] == "Jack"):
        return { 
            'name': 'Jack', 
            'phone': '(512) 757-7001', 
            'country': 'Ca' 
        }
 
    return "Not found"
```

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FxdR8HbgNxxmWzrMSxrha%2Fimage.png?alt=media&#x26;token=b76f47b9-43aa-488b-8416-15bdfa81f2e8" alt=""><figcaption></figcaption></figure>

8. To ensure that the function is working. Click on Test. Provide a test name and provide following sample value in the test. Click on Create.

{ "name": "rose" }

!\[Graphical user interface, application

Description automatically generated]\(<https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FkOKafD4sDkuAEUYTBasG%2F5?alt=media>)

9. &#x20;Now Click on Deploy and then Test. The sample response is also shown in below:

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FYdUsoudoOwSFphKqsH83%2Fimage.png?alt=media&#x26;token=4b0fd860-8bc0-465d-9d0f-b037784b5ac9" alt=""><figcaption></figcaption></figure>

10. &#x20;Now that you have successfully created AWS-Lambda function, you can use this with iX Hello integration to build custom Apps. Follow the next document to integrate Amazon Lambda with iX Hello.
