Note: This lambda has been deprecated in the latest "Cancel Architecture".
This package is intended to be used as a Lambda-based Node.js/PHP Listener to listen to a Kinesis Stream.
It uses the NYPL PHP Microservice Starter.
This package adheres to PSR-1, PSR-2, and PSR-4 (using the Composer autoloader).
- Node.js 6.10.2
- PHP >=7.0
Homebrew is highly recommended for PHP:
brew install php71
- Clone the repo.
- Install required dependencies.
- Run
npm install
to install Node.js packages. - Run
composer install
to install PHP packages. - If you have not already installed
node-lambda
as a global package, runnpm install -g node-lambda
.
- Run
- Setup configuration files.
- Copy the
.env.sample
file to.env
. - Copy
config/var_qa.env.sample
toconfig/var_qa.env
andconfig/var_production.env.sample
toconfig/var_production.env
.
- Copy the
Various files are used to configure and deploy the Lambda.
.env
is used locally for the following purpose(s):
- By
node-lambda
for deploying to and configuring Lambda in all environments.- You should use this file to configure the common settings for the Lambda (e.g. timeout, role, etc.) and include AWS credentials to deploy the Lambda.
Configures npm run
commands for each environment for deployment and testing. Deployment commands may also set the proper AWS Lambda VPC and security group.
"scripts": {
"deploy-development": "./node_modules/.bin/node-lambda deploy -e development -f config/var_development.env -S config/event_sources_development.json --profile nypl-sandbox --role arn:aws:iam::224280085904:role/lambda_basic_execution",
"deploy-qa": "./node_modules/.bin/node-lambda deploy -e qa -f config/var_qa.env -S config/event_sources_qa.json --profile nypl-sandbox --role arn:aws:iam::224280085904:role/lambda_basic_execution",
"deploy-production": "./node_modules/.bin/node-lambda deploy -e production -f config/var_production.env -S config/event_sources_production.json --profile nypl-digital-dev --role arn:aws:iam::946183545209:role/lambda-full-access",
"test-event": "./node_modules/.bin/node-lambda run -f config/var_app -j events/kinesis_hold_edd_success.json -x events/context.json"
},
Configures environment variables common to all environments.
Configures environment variables specific to each environment.
Configures Lambda event sources (triggers) specific to each environment.
To use node-lambda
to process the sample event(s), run:
npm run test-event
The branches and the environments they are deployed to:
Branch | Environment | AWS Account |
---|---|---|
development | development | nypl-sandbox |
qa | qa | nypl-digital-dev |
master | production | nypl-digital-dev |
To deploy to the Development, QA or Production environment, run the corresponding command. For exampe,
npm run deploy-development
or
npm run deploy-production
Alternatively, if either development, qa, or master branch is pushed to the remote, Travis will be triggered and deploy the branch to the environment respectively.
Please see this repo's Wiki