Skip to content

Instantly share code, notes, and snippets.

@sj82516
Last active January 27, 2019 02:40
Show Gist options
  • Select an option

  • Save sj82516/6769da465a33ae123428fe7e7511ee59 to your computer and use it in GitHub Desktop.

Select an option

Save sj82516/6769da465a33ae123428fe7e7511ee59 to your computer and use it in GitHub Desktop.
aws-cdk-test
import path = require('path');
import cdk = require('@aws-cdk/cdk');
import lambda = require('@aws-cdk/aws-lambda');
import event = require('@aws-cdk/aws-events');
export class AwsCdkStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const fn = new lambda.Function(this, 'MyLambda', {
// 可指定當地路徑或s3 等
code: lambda.Code.asset(path.join(__dirname, 'my-lambda-handler')),
handler: 'index.main',
runtime: lambda.Runtime.NodeJS810,
environment: {
STACK_NAME: "HelloWorld",
REGION: props && props.env && props.env.region
}
});
const scheduleEvent = new event.EventRule(this, 'ScheduledEvent', {
scheduleExpression: 'cron(0/2 * * * ? *)'
})
scheduleEvent.addTarget(fn);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment