This module installs as a module on AWS Lambda, as a zip file. You can either just download the zip from
/dist and upload it via your AWS console or install it via aws-cli. The first one might not always work so the method with aws-cli described below is recommended:
npm install goldwasher-aws-lambda cd node_modules/goldwasher-aws-lambda/dist/ aws lambda create-function --function-name goldwasher --timeout 60 --zip-file fileb://goldwasher-aws-lambda.zip
You can of course replace
goldwasher with your name of choice and
60 with a lower timeout if necessary.
If you later need to overwrite it and the function name already exists on AWS, use this instead:
aws lambda update-function-code --function-name goldwasher --zip-file fileb://goldwasher-aws-lambda.zip
The module accepts the usual parameters of goldwasher-needle with the exception that the
options parameters have been merged. This simply means that the first parameter,
url, has been removed and must instead be added as a property on the
url: ''goldwasher:selector: 'h1'
See how to use this in the examples below or simply paste it as a sample event in the AWS console.
If you feel like changing the code and have installed the development dependencies, you can automatically build a new zip file from the main folder:
This will create a new zip that can be installed with the commands mentioned under installation.
In this example we will show how to consume the Lambda function from a client. First, install the aws-sdk:
npm install aws-sdk
In this example, we will use a config file for our AWS credentials. Remember to replace the values below with your own.
It is extremely important that you do not push this file to your git repository or any other public place. I highly recommend using environment variables instead. I also recommend creating a user on AWS that only has the permission
AWSLambdaRole to run this.
"accessKeyId": "akid""secretAccessKey": "secret""region": "us-east-1"
var AWS = ;AWSconfig;var lambda = ;lambda;