Last active
January 27, 2019 02:40
-
-
Save sj82516/6769da465a33ae123428fe7e7511ee59 to your computer and use it in GitHub Desktop.
aws-cdk-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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