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-1.0.78.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b696b061483f3c12ce8427cdec72a0b695aaad47d3fa16f3c8940cefdc2cec7e |
|
MD5 | 39fd7bf97f80df491a1a3dd3b9bb636d |
|
BLAKE2b-256 | d455c73c97301d6d15ffb8f91b28be09cdcd029572e1d97d02b7fe119b905b38 |
Close
Hashes for renovosolutions.aws_cdk_one_time_event-1.0.78-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60938ddea219f3fec753e1865363297133cacda305ef71a801a8286098817cc5 |
|
MD5 | 7d389e7693be30b53973c75e1a2d4260 |
|
BLAKE2b-256 | 6b2597633b8817dc9f222e2c287c86e0bd04d8bfda62ed4eb4a3ae0b2306443f |