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.47.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cce3313b3efdf2408386d75ca0a9656e66ede588d266803b013699ba3af5314a |
|
MD5 | 10402f6fcd76aade88b4f5a15c9ec29c |
|
BLAKE2b-256 | 21063d682627f555b042584d1d0f9a59a21ad6ccf62efee1b9a41d0effe8ec30 |
Close
Hashes for renovosolutions.aws_cdk_one_time_event-2.1.47-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46c45bebc95f14c046c1a97f9c91578a616a928fb4ba72339114bd0a6102f7f7 |
|
MD5 | 519fc2c196f4226f8b4e4dd196628b01 |
|
BLAKE2b-256 | f793c7011b7895b3e36a4b559059eac72e7f12e74456e0e4e8d73e1fa4ed1963 |