constructor()

in nodejs14.x/scheduled-job/cdk/cdk/lib/cdk-stack.ts [9:34]


    constructor(scope: App, id: string, props: StackProps) {
        super(scope, id, props);

        new CfnParameter(this, 'AppId');

        // The code will be uploaded to this location during the pipeline's build step
        const artifactBucket = process.env.S3_BUCKET!;
        const artifactKey = `${process.env.CODEBUILD_BUILD_ID}/function-code.zip`;

        // This is a Lambda function config associated with the source code: scheduled-event-logger.js
        const scheduledEventLoggerFunction = new lambda.Function(this, 'scheduledEventLogger', {
            description: 'A Lambda function that logs the payload of scheduled events.',
            handler: 'src/handlers/scheduled-event-logger.scheduledEventLoggerHandler',
            runtime: lambda.Runtime.NODEJS_14_X,
            code: lambda.Code.fromBucket(
                s3.Bucket.fromBucketName(this, 'ArtifactBucket', artifactBucket),
                artifactKey,
            ),
        });

        new events.Rule(this, 'SimpleCWEEvent', {
            // Runs every hour at the top of the hour (for example, at 5:00 and then at 6:00)
            schedule: events.Schedule.expression('cron(0 * * * ? *)'),
            targets: [new LambdaFunction(scheduledEventLoggerFunction)],
        });
    }