@softchef/cdk-schedule-function
TypeScript icon, indicating that this package has built-in type declarations

2.0.94 • Public • Published

CDK Construct - Schedule Function

npm version Release npm

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...

Architecture


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

Roadmap

  • DispatchTarget performance up(StepFunction or SQS)
  • Export more internal resource
  • DynamoDB indexs/capacity best optimization

Package Sidebar

Install

npm i @softchef/cdk-schedule-function

Weekly Downloads

17

Version

2.0.94

License

Apache-2.0

Unpacked Size

30.6 MB

Total Files

5562

Last publish

Collaborators

  • softchef-iot-lab