Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving CDK example app to latest CDK version #706

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
StewartW marked this conversation as resolved.
Show resolved Hide resolved
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"
}
}