https://github.com/softchef/cdk-schedule-function
https://github.com/softchef/cdk-schedule-function
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/softchef/cdk-schedule-function
- Owner: SoftChef
- License: apache-2.0
- Created: 2021-06-26T17:31:30.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-08-09T01:51:46.000Z (almost 4 years ago)
- Last Synced: 2024-11-11T03:43:52.806Z (over 1 year ago)
- Language: TypeScript
- Size: 3.36 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CDK Construct - Schedule Function
[](https://badge.fury.io/js/%40softchef%2Fcdk-schedule-function)


ScheduleFunction is CDK Construct, provide lambda functions to manage your schedule with Amazon EventBridge service. It is arrange one-time or multi-times schedule to invoke specify lambda functions. It is not permanent recurly, because you can use original EventBridge rule.
You can hook the lambda functions to your API Gateway to manage your schedules. The schedules will store in the DynamoDB table, you can tracking the schedules status, execution results, etc...

---
## Installation
```
npm install @softchef/cdk-schedule-function
or
yarn add @softchef/cdk-schedule-function
```
## Usage
```
const scheduleFunction = new ScheduleFunction(stack, 'ScheduleFunction', {});
scheduleFunction.addTargetFunction('CreateJob', targetFunction);
```
The Target Function is actual to execute function for business logic. The 'CreateJob' is targetType to identify this function when schedule running.
You can add many targetFunction to process different logic.
## Hook
```
const restApi = new apigateway.RestApi(stack, 'RestApi');
const rootResource = restApi.root.addResource('schedules');
rootResource.addMethod('POST', apigateway.LambdaIntegration(scheduleFunction.createScheduleFunction)); // Create schdules
rootResource.addMethod('GET', apigateway.LambdaIntegration(scheduleFunction.listSchedulesFunction)); // List schdules
const scheduleResource = rootResource.addResource('{scheduleId}');
scheduleResource.addMethod('GET', apigateway.LambdaIntegration(scheduleFunction.fetchScheduleFunction)); // Fetch schdule
scheduleResource.addMethod('PUT', apigateway.LambdaIntegration(scheduleFunction.updateSchedulesFunction)); // Update schdule
scheduleResource.addMethod('PUT', apigateway.LambdaIntegration(scheduleFunction.deleteSchedulesFunction)); // Delete schdule
more...
```
## Example
[Demo stack](./src/demo)
## Roadmap
- DispatchTarget performance up(StepFunction or SQS)
- Export more internal resource
- DynamoDB indexs/capacity best optimization