Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suzukiryuichiro/osouji-reminder-serverless
https://github.com/suzukiryuichiro/osouji-reminder-serverless
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/suzukiryuichiro/osouji-reminder-serverless
- Owner: SuzukiRyuichiro
- Created: 2024-08-21T05:43:05.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-12-11T04:17:15.000Z (25 days ago)
- Last Synced: 2024-12-11T05:20:29.223Z (25 days ago)
- Language: Python
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Serverless Framework Python Scheduled Cron on AWS
This template demonstrates how to develop and deploy a simple cron-like service running on AWS Lambda using the Serverless Framework.
Detailed information about cron expressions in available in official [AWS docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions).
## Usage
### Deployment
This example is made to work with the Serverless Framework dashboard, which includes advanced features such as CI/CD, monitoring, metrics, etc.
In order to deploy with dashboard, you need to first login with:
```
serverless login
```and then perform deployment with:
```
serverless deploy
```After running deploy, you should see output similar to:
```
Deploying "aws-python-scheduled-cron" to stage "dev" (us-east-1)✔ Service deployed to stack aws-python-scheduled-cron-dev (146s)
functions:
rateHandler: aws-python-scheduled-cron-dev-rateHandler (2.2 kB)
```There is no additional step required. Your defined schedules becomes active right away after deployment.
### Local invocation
In order to test out your functions locally, you can invoke them with the following command:
```
serverless invoke local --function rateHandler
```After invocation, you should see output similar to:
```
INFO:handler:Your cron function ran at 15:02:43.203145
```### Bundling dependencies
In case you would like to include 3rd party dependencies, you will need to use a plugin called `serverless-python-requirements`. You can set it up by running the following command:
```
serverless plugin install -n serverless-python-requirements
```Running the above will automatically add `serverless-python-requirements` to `plugins` section in your `serverless.yml` file and add it as a `devDependency` to `package.json` file. The `package.json` file will be automatically created if it doesn't exist beforehand. Now you will be able to add your dependencies to `requirements.txt` file (`Pipfile` and `pyproject.toml` is also supported but requires additional configuration) and they will be automatically injected to Lambda package during build process. For more details about the plugin's configuration, please refer to [official documentation](https://github.com/UnitedIncome/serverless-python-requirements).