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
pluginsdirectory in root of the repo - Modify
plugins-interfacepackage'spyproject.tomlso it includes plugin's API package as its dependency ( you can base onserverless-scheduler-html-checker-apiusage in there) - Run
poetry lock --no-updateinplugins-interface - Add a directory named
plugins-<your-plugin-name>interraform/deployments/<env>and copy overplugins-serverless-scheduler-html-checker'sterragrunt.hcl, modify the copiedterragrunt.hclso it points toterraform/terragrunt.hclin the root directory of the plugin - Run
utils/complete_build.shto 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_entrypointscript, that outputs the zip generated for a project to.packaging/result/lambda.zipfile (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
terraformdirectory, 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 withcommonpackage. This is really only usable with Python based pluginsplugins_layer_arn- (optional support) ARN of the Lambda layer withplugins-interfacepackage. This is really only usable with Python based plugins
- Plugin's directory contains a
<plugin-name>-apipython package that exports package followingserverless-scheduler-<>-apinaming scheme and containsplugin_exportsubpackage, which exports:
ENUM_MAPPING- dict fromstrtostr, keys are ENUM identifiers, while values are string identifiers, e.g.HTMLMonitorJob:html_monitor_jobCLASS_MAPPING- dict fromstrtoclass, 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.