AWS CDK Construct Library to create one time event schedules.
Project description
cdk-library-one-time-event
An AWS CDK Construct library to create one time event schedules.
Features
-
Create two types of event schedules easily:
- On Deployment: An one time event schedule for directly after deployment. Defaults to 10mins after.
- At: A one time even schedule for any future
Date()
API Doc
See API
Examples
Typescript - run after deploy, offset 15mins
import * as cdk from '@aws-cdk/core';
import * as lambda from '@aws-cdk/aws-lambda';
import * as oneTimeEvents from '@renovosolutions/cdk-library-one-time-event';
export class CdkExampleLambdaStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const handler = new lambda.Function(this, 'handler', {
runtime: lambda.Runtime.PYTHON_3_8,
code: lambda.Code.fromAsset(functionDir + '/function.zip'),
handler: 'index.handler',
});
new events.Rule(this, 'triggerImmediate', {
schedule: new oneTimeEvents.OnDeploy(this, 'schedule', {
offsetMinutes: 15
}).schedule,
targets: [new targets.LambdaFunction(this.handler)],
});
Typescript - run in 24 hours
import * as cdk from '@aws-cdk/core';
import * as lambda from '@aws-cdk/aws-lambda';
import * as oneTimeEvents from '@renovosolutions/cdk-library-one-time-event';
export class CdkExampleLambdaStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const handler = new lambda.Function(this, 'handler', {
runtime: lambda.Runtime.PYTHON_3_8,
code: lambda.Code.fromAsset(functionDir + '/function.zip'),
handler: 'index.handler',
});
var tomorrow = new Date()
tomorrow.setDate(tomorrow.getDate() + 1)
new events.Rule(this, 'triggerImmediate', {
schedule: new oneTimeEvents.At(this, 'schedule', {
date: tomorrow
}).schedule,
targets: [new targets.LambdaFunction(this.handler)],
});
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for renovosolutions.aws-cdk-one-time-event-2.1.49.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb77acab563f3733bf652f3793f93cac81759045168de88c0962d95347f1d4cc |
|
MD5 | 85adce1ec9de06004f6845d05fe14b08 |
|
BLAKE2b-256 | ed1f7d004ca8ce23b122298b04c85c529a4c54036fd7973d7ce1cee923386be0 |
Close
Hashes for renovosolutions.aws_cdk_one_time_event-2.1.49-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee51a65097a686f7cee9e8350f1106b0424b91282edb35694cb7359c990e1afc |
|
MD5 | c767c01325665f7d8f32d508dc0825a4 |
|
BLAKE2b-256 | 8e93f57ec402123107879c6e681d5618644bbc2c721f97cc866781dea0bb5e54 |