# 3.Setting Up AWS Lambda

AWS Lambda is **a serverless compute service that runs your code in response to events and automatically manages the underlying compute resources for you**. You can use AWS Lambda to extend other AWS services with custom logic, or create your own back-end services that operate at AWS scale, performance, and security.

{% hint style="info" %}
While the entire setup make sure the **region** selected as **Mumbai** . This can be seem at the top right near to the username.

This should be ensured while creating both Lambda Function and Lambda Layer
{% endhint %}

1. Visit <https://portal.aws.amazon.com/billing/signup#/start>
2. You can complete the Sign Up process as mentioned in the video
3. Select Lambda from the services section or you can search in the search bar
4. Now click on Create Function

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2FJOXYy2JUcCVZV7pDeZhA%2FScreenshot%202021-10-24%20170717.png?alt=media\&token=10e1efb5-db80-42da-b380-9f8f6b43f4c1)

5\. Give a Function name of your choice and Runtime as Python 3.7 and click on Create Function

6\. Now click on Upload from followed by select .zip . Now choose LambdaFunction.zip that is shared&#x20;

7\. Fill the details of the `token.json` , `credentials.json` with the content which you have in the folder

8\.  Go the the Configuration tab and select General Configuration and click on edit

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2FeLWsDbLnWLr9KK8dGSLe%2FScreenshot%202021-10-24%20171725.png?alt=media\&token=468bb25f-a2c5-4bff-99b3-7495328ab876)

Now click on Edit. Provide Memory as 1024 MB and time out as 7 min (you can reduce to 5 min also) and Save

9\. Navigate to Environmental Variables section under the same **Configuration Tab** and click on **Edit**

<figure><img src="https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2F8Kv9rBy1QJ5YjgwMIKmO%2FScreenshot%202022-03-08%20165717.png?alt=media&#x26;token=2e458d52-0d80-46fc-89e7-43a130fc8d34" alt=""><figcaption></figcaption></figure>

10\. Fill the fields with your credentials and **Save**

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2FzFDugVkc9UosEOH7lDWw%2FScreenshot%202021-10-24%20171947.png?alt=media\&token=4104e5c4-0c7a-41ea-9cf8-9bd209064032)

11\. Now click on Add trigger and search EventBridge(CloudWatch Events)

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2FdmjZgsoFTimw2jqrYQAj%2FScreenshot%202021-10-24%20172101.png?alt=media\&token=a0902a71-ce49-4d92-b429-6daf88fa7130)

12\. Provide the details as follows

Rule name : dailyAuthenticate

Schedule expression : cron(30 3 ? \* MON-FRI \*)

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2FbYmIfH5fP3zqEDK7smfC%2FScreenshot%202021-10-24%20172443.png?alt=media\&token=10821902-9cbb-4271-b1fd-d51ede646c96)

here 30 represent minute and 3 is the hour.We need to provide GMT Time here.So 3:30AM GMT is 9:00 AM IST

You can use any other time if you what to authorise with help of this converter <https://savvytime.com/converter/gmt-to-ist>

Also you can add multiple trigger as well.Click on Add

13 . Now we can add a Lambda layer

{% hint style="info" %}
A Lambda layer is **an archive containing additional code**, such as libraries, dependencies, or even custom runtimes. When you include a layer in a function, the contents are extracted to the /opt directory in the execution environment.
{% endhint %}

search S3 in the search bar and select first option

14 . Now click on Create bucket

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2FRWkBJQrpK9QubQbbVKB7%2FScreenshot%202021-10-24%20173417.png?alt=media\&token=c92b3277-495b-4b89-88ff-44ea14510799)

15\. Give a bucket name and leave the rest of the options as default and create bucket

16\. Select the bucket and click on Upload and upload LambdaLayer.zip

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2FiigczWfjQOoUXj47hlQO%2FScreenshot%202021-10-24%20173417.png?alt=media\&token=7b73fd92-e947-417f-a4b6-b82bc76c6fb6)

17\. Now select the LambdaLayer.zip and copy the URL

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2F1Jm582EQrMnnbBQUkpMf%2FScreenshot%202021-10-24%20174055.png?alt=media\&token=6d75ad55-ba4e-4bf8-bee7-4c2454bfbf59)

18\. Now go back to Lambda service and select Layers followed by Create Layer

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2F262qtToOm2AekMmDPXSU%2FScreenshot%202021-10-24%20174319.png?alt=media\&token=57a69742-c456-447b-b7a5-e69f0524024a)

19\. Provide Layer Configuration as follow

Don't forget to paste the URL in that text box and click on Create

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2FQ5cnbzK8zdIonz7OXhVG%2FScreenshot%202021-10-24%20174455.png?alt=media\&token=677273fc-f5fc-429c-b134-c41b0b6ca1a5)

Now go back to the page of Lambda function where the code is available , scroll to the bottom and click on Add Layer

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2FehWk85eijjSiWFbAvgGd%2FScreenshot%202021-10-24%20174840.png?alt=media\&token=e26f8bc9-3e49-4a5c-93fd-1e9217c7812e)

From Custom Layers select the Layer you have just created ( here its *cdsl* ) and click on Add

{% hint style="info" %}
Before Testing you must ensure that "Conversation View" is turned **OFF** in the GMail settings.
{% endhint %}

<figure><img src="https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2FffFj8YPnQKMqdR875NrV%2FScreenshot%202022-10-31%20162905.png?alt=media&#x26;token=dcdd92be-cb89-4e68-8377-63c74c384d9e" alt=""><figcaption><p>Under G-Mail Settings</p></figcaption></figure>

We are almost over now :tada:

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2Fq6JCZzEVmXNOEpxsFRYe%2FScreenshot%202021-10-24%20175738.png?alt=media\&token=42f4e0d9-65be-47fc-9515-096aa8de3b73)

Now Click on Deploy and Test , you will be able to see the OTP from CDSL . Our Authorisation has been done successfully , now you call sell your stock from Holdings without manual authorization :clap:

![](https://3955321061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp7u3ewUbKREM72nYbdNg%2Fuploads%2Fjd5sq5OjeIsRiPhq3kkf%2FScreenshot%202021-10-24%20180042.png?alt=media\&token=3b865e78-5a10-4c07-939a-3aa1038163f6)

Note : Refer to **Version History** for an update


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://abelcheruvathoor.gitbook.io/autocdsl/setup/3.setting-up-aws-lambda.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
