Saturday 25 February 2023

Aws Lambda and Python Automation

This is not a tutorial for Lambda

A script that takes Guardian Home Page headlines and send it automatically Using Lambda (AWS Lambda)


1. Wrote the code, I won't share the full code, but you can have a look at this small snippet or in the YouTube video. 


 2. Create a Lambda Function:


We also created EventBridge Cloudwatch trigger for our cron which will run the code every minutes. 

3. Packages uploaded as python.zip
If it is not zipped in this structure, you might face some issues depending on your system config.

4. Used docker to create an instance of python3.9 container, connected to it from inside


Going into the folder where I want to download my packages, e.g. I want to do pip install requests -t .
Meaning, I want to install in that particular folder.

5. Now I want to access the container from the vscode. 

 

These steps helped me create volume that helped my container python3.6 access the local folder. I installed packages here and zipped to upload as a lambda layer. The picture of WatchCloud shows my code ran just fine. 














No comments:

Post a Comment