Hello World AWS Lambda
Hello World AWS Lambda
5 min intro on how to use AWS Lambda with nodejs from the cli (you will need to create the roles and user profiles before).
$ export | grep -i aws AWS_ACCESS_KEY=*** AWS_SECRET_KEY=***** $ aws lambda list-functions { "Functions": [] } $ mkdir testLambda $ cd testLambda $ emacs hello.js ... $ cat hello.js exports.hello = function (event, context) { console.log("sup!!"); context.succeed("hello world!"); } $ zip -r hello.zip hello.js # NOTE: handler is <filename-without-js>.<exported name> # in this case file is hello.js and exports."hello", so handler is hello.hello $ aws lambda create-function --function-name test --runtime nodejs4.3 --role arn:aws:iam::<id>:role/lambda-test --handler hello.hello --publish --zip-file fileb://$(pwd)/hello.zip { "CodeSha256": "JF3Cl7mfTN6S/tHbISyyCHQOw9m7s2onAEFXyAWKvqY=", "FunctionName": "test", "CodeSize": 235, "MemorySize": 128, "FunctionArn": "arn:aws:lambda:us-east-1:<id>:function:test", "Version": "1", "Role": "arn:aws:iam::<id>:role/lambda-test", "Timeout": 3, "LastModified": "2016-11-04T20:24:39.226+0000", "Handler": "hello", "Runtime": "nodejs4.3", "Description": "" } $ aws lambda invoke --function-name test --log-type Tail --invocation-type RequestResponse out.txt { "LogResult": "U1RBUlQgUmVxdWVz...", "StatusCode": 200 } $ cat out.txt "hello world!"