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.0.68.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec1dd6dbdd68d83aefe959cb4c670b9ce5b9c743cbeae72ffb6d67be47e2839d |
|
MD5 | 969359cb6c9c546b8260a16ce10320e7 |
|
BLAKE2b-256 | b8af402f6d74f8110a778d5d8dd9084203a710bf401d47ff47e857ff1b0a9b92 |
Close
Hashes for renovosolutions.aws_cdk_one_time_event-2.0.68-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48e083cf98aa8ef699b415177971ebd4038b119617c8dd3af50e0dd0fcb545cd |
|
MD5 | 679f600cd63428e1bd3bb8fd5663a7c9 |
|
BLAKE2b-256 | d4fa5d7d2cd27555c6e822c4afeb522556e933871cb8d136716c7305f89f494f |