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.24.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b1bf179a19a70d100d45b0679b7981d6cd5be2aade791de75f4f7c68c6c0670 |
|
MD5 | ceb6c0e4425711e12d82234b8d3f9abf |
|
BLAKE2b-256 | bf951fa6903f99429f14e245fa0fabaa332b8d96f0d2a7fbe1a48d4b3d5c4244 |
Close
Hashes for renovosolutions.aws_cdk_one_time_event-2.1.24-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf52c4eef096ede73c1b3d9746d0a6fb18c1fd7a5b762a1cc49a717348746839 |
|
MD5 | 6d23aaae7c0eeb279cf4406be57275bf |
|
BLAKE2b-256 | 530a0aa30616fa7d41a5cf566f9636e0aebff97963730af6284fb086fab5694a |