Skip to content

Commit

Permalink
Moving CDK example app to latest CDK version (#706)
Browse files Browse the repository at this point in the history
* Moving CDK example app to latest CDK version

* Update samples/sample-cdk-app/index.ts

---------

Co-authored-by: Javy de Koning
Co-authored-by: Stewart Wallace
Co-authored-by: Simon Kok
  • Loading branch information
javydekoning authored Apr 19, 2024
1 parent 32e9ecf commit 67d9678
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
3 changes: 3 additions & 0 deletions samples/sample-cdk-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cdk.out/
node_modules/
package-lock.json
2 changes: 1 addition & 1 deletion samples/sample-cdk-app/cdk.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"app": "node index"
"app": "npx ts-node --prefer-ts-exts index.ts"
}
16 changes: 7 additions & 9 deletions samples/sample-cdk-app/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
// Copyright Amazon.com Inc. or its affiliates.
// SPDX-License-Identifier: Apache-2.0

import events = require('@aws-cdk/aws-events');
import targets = require('@aws-cdk/aws-events-targets');
import lambda = require('@aws-cdk/aws-lambda');
import cdk = require('@aws-cdk/core');
import { App, Stack, Duration } from 'aws-cdk-lib';
import { aws_lambda as lambda, aws_events as events, aws_events_targets as targets } from 'aws-cdk-lib';

import fs = require('fs');

export class LambdaCronStack extends cdk.Stack {
constructor(app: cdk.App, id: string) {
export class LambdaCronStack extends Stack {
constructor(app: App, id: string) {
super(app, id);

const lambdaFn = new lambda.Function(this, 'Singleton', {
code: new lambda.InlineCode(
fs.readFileSync('handler.py', { encoding: 'utf-8' }),
),
handler: 'index.main',
timeout: cdk.Duration.seconds(300),
runtime: lambda.Runtime.PYTHON_3_8
timeout: Duration.seconds(300),
runtime: lambda.Runtime.PYTHON_3_12
});
// Run every day at 6PM UTC
// See https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html
Expand All @@ -29,6 +27,6 @@ export class LambdaCronStack extends cdk.Stack {
}
}

const app = new cdk.App();
const app = new App();
new LambdaCronStack(app, 'LambdaCronExample');
app.synth();
12 changes: 5 additions & 7 deletions samples/sample-cdk-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lambda-cron",
"version": "0.23.0",
"version": "0.24.0",
"description": "Running a Lambda on a schedule",
"private": true,
"scripts": {
Expand All @@ -15,13 +15,11 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@types/node": "^8.10.38",
"typescript": "^3.2.4"
"@types/node": "^20.0.0",
"typescript": "^5.4.4"
},
"dependencies": {
"@aws-cdk/aws-events": "*",
"@aws-cdk/aws-events-targets": "*",
"@aws-cdk/aws-lambda": "*",
"@aws-cdk/core": "*"
"aws-cdk-lib": "^2.135.0",
"constructs": "^10.3.0"
}
}

0 comments on commit 67d9678

Please sign in to comment.