Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to run es6 components, specifically promises and generators, in aws lambda functions

ES6 usage requires --harmony flag in node v0.12.3.

Is there a way to do so for an aws lambda function?

like image 403
Swaraj Giri Avatar asked Sep 27 '22 22:09

Swaraj Giri


2 Answers

You can use babel to transform es6/es7 to be compatible with node 0.10.x:

http://www.rricard.me/es6/aws/lambda/nodejs/2015/11/29/es6-on-aws-lambda.html

EDIT:

There is also a really cool AWS lambda deployer called Apex with that you can transform and deploy es6/es7 code easily! Examples: https://github.com/apex/apex/tree/master/_examples/babel-webpack

EDIT2: There is an other AWS lambda deployer called Gordon which also helps you integrate lambda with other services such as:

  • APIGateway
  • Scheduled CloudWatch Events (cron)
  • CloudWatch Events
  • Dynamodb Streams
  • Kinesis Streams
  • S3

They also have a lot of useful examples

like image 198
barczag Avatar answered Nov 02 '22 06:11

barczag


AWS Lambda use v0.10.36, but anyway I think we can try in this way

var spawn = require("child_process").spawn;
var child = spawn('node', [ "--harmony", "es6.js" ], {
  cwd: __dirname
});
like image 23
zhiyelee Avatar answered Nov 02 '22 04:11

zhiyelee