Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opsdisk/aquabot_lambda
AWS Lambda implementation of aquabot
https://github.com/opsdisk/aquabot_lambda
lambda python twitter
Last synced: 5 days ago
JSON representation
AWS Lambda implementation of aquabot
- Host: GitHub
- URL: https://github.com/opsdisk/aquabot_lambda
- Owner: opsdisk
- Created: 2018-07-28T21:49:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-28T22:35:22.000Z (about 6 years ago)
- Last Synced: 2025-01-19T10:11:46.706Z (6 days ago)
- Topics: lambda, python, twitter
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python script to Lambda function
This is a project that turned the [aquabot Python script](https://github.com/opsdisk/aquabot) into an AWS Lambda function.# Basic Setup
* CloudWatch Event trigger cron job in UTC: `cron(15 16 * * ? *)` - replaces time.sleep() in a while loop.
* No VPC
* Handler: `aquabot.lambda_handler`
* Role has `AWSLambdaBasicExecutionRole` and `AWSLambdaMicroserviceExecutionRole` policies
* Security Group: Outbound 443 only for data.edwardsaquifer.org and twitter.com
* Test event is an empty dictionary: `{}`
* Can read twitter_creds.json; tested with environment variables and that also worked.# Create a .zip deployment package
The .zip file contains all the code and the additional libraries installed (through pip).
## No virtualenv
```bash
cd aquabot_lambda
pip3 install -r requirements.txt -t .
zip -qr9 ../lambdapackage.zip .
```## virtualenv
* Easiest to create virtual environment in the parent folder of the project
* Then add site-packages directory after initially creating the zip folder```bash
virtualenv -p python3 .venv
source .venv/bin/activate
pip install -r aquabot_lambda/requirements.txt
``````bash
cd aquabot_lambda
zip -qr9 ../lambdapackage.zip .
cd $VIRTUAL_ENV/lib/python3.6/site-packages
zip -qru9 ../../../../lambdapackage.zip .
cd -
deactivate
```