While the core functionality (scheduler + UI) is defined in this repo, handlers for different job types should be kept in plugins/<specific plugin>
directory, e.g. for HTMLMonitorJob
consumer there is plugins/serverless-scheduler-html-checker
directory (git submodule).
- Add it to the
plugins
directory in root of the repo - Modify
plugins-interface
package'spyproject.toml
so it includes plugin's API package as its dependency ( you can base onserverless-scheduler-html-checker-api
usage in there) - Run
poetry lock --no-update
inplugins-interface
- Add a directory named
plugins-<your-plugin-name>
interraform/deployments/<env>
and copy overplugins-serverless-scheduler-html-checker
'sterragrunt.hcl
, modify the copiedterragrunt.hcl
so it points toterraform/terragrunt.hcl
in the root directory of the plugin - Run
utils/complete_build.sh
to prepare the packages to be uploaded - Run
utils_complete_deploy.sh
(with proper options for your env) to deploy the app with new plugin support
The plugins are expected to follow common project structure, so they work seamlessly with existing build system. Namely:
- Plugin defines
bin/package_lambda_entrypoint
script, that outputs the zip generated for a project to.packaging/result/lambda.zip
file (in plugin's root directory). It's up to the developer to define if this script will rely onserverless-scheduler
's build system that's used for core packages or define their own logic. - Plugin defines
terraform
directory, that contains all the logic needed to deploy the functionality. The following variables should be accepted:
aws_region
- in what region to deployservice
- to be used in tags as 'Service'stage
- to be used in tags as 'Stage'prefix
- what value to prefix the deployed objects' names withlambda_zip_path
- path to zip file that should be used by the consumer Lambda (build system will automatically insert the zip built in step 1.)distribution_sns_topic_arn
- ARN of the SNS topic that deployment should monitor for incoming events with matching job_typecommon_layer_arn
- (optional support) ARN of the Lambda layer withcommon
package. This is really only usable with Python based pluginsplugins_layer_arn
- (optional support) ARN of the Lambda layer withplugins-interface
package. This is really only usable with Python based plugins
- Plugin's directory contains a
<plugin-name>-api
python package that exports package followingserverless-scheduler-<>-api
naming scheme and containsplugin_export
subpackage, which exports:
ENUM_MAPPING
- dict fromstr
tostr
, keys are ENUM identifiers, while values are string identifiers, e.g.HTMLMonitorJob
:html_monitor_job
CLASS_MAPPING
- dict fromstr
toclass
, keys are string identifiers (values fromENUM_MAPPING
), while values are classes that map to a jobType
The reference implementation can be seen in previously mentioned plugins/serverless-scheduler-html-checker
.
serverless-scheduler-plugin-example
can be treated as an example of just the API part, even though there's no real logic defined in it.
It's up to the user to define if the consumer should use SQS as a "buffer" before consuming the event by Lambda or not. In practice the consumer doesn't even have to be a Lambda function, although it's recommended for keeping the whole model serverless.
Installed plugins have access to the common
layer (via the ARN provided), but they don't have access to plugins
layer.
The reasoning here is that a scope of a plugin should be completely covered by the single plugin.