- AWS Serverless (Lambda) function that interacts with ResearchHub's ElasticSearch instance
- Build using the Serverless Framework
- Supports unit testing and debugging with Visual Studio Code
- Install Serverless Framework globally
npm install -g serverless
- Install
NPM
modules
npm install
- Obtain Temporary AWS credentials for UoA (Note: only valid for 1 hour): Running and testing locally will not succeed without AWS credentials. Instructions for accessing the credentials are on the Auckland Uni wiki.
- Generated credentials are located in ~/.aws/credentials. Take note of the profile name for the credentials. Currently "saml" is the default profile at the time of writing this.
- Passing in the aws credentials to the deploy and test commands can be done by adding arguments after a double dash to the run/test commands. This applies to any npm command. e.g.
- Deploying with the default sandbox stage and saml profile:
npm run deploy -- --aws-profile saml
To run locally simply execute:
npm start -- --aws-profile <profile> --stage <stage>
Inside Visual Studio Code hit F5
and select Debug
as config file. Attach breakpoints as desired.
To run all unit tests once simply execute:
npm test -- --aws-profile <profile> --stage <stage>
To run all unit tests and have them watch your files for changes:
npm run testw -- --aws-profile <profile> --stage <stage>
To deploy to AWS execute:
- By default it deploys to the
dev
stage if you don't provide a stage parameter
npm deploy -- --aws-profile <profile> --stage <stage>
To get information about the currently deployed endpoints, region, stage, layers and other things, execute:
sls info
For info on a specific stage, and AWS account profile, use the profile and stage flags. e.g.:
sls info --stage test --aws-profile uoa-its-nonprod
sls invoke -f hub-search-proxy
- For general Serverless Framework help run:
sls help
- Serverless Mocha Plugin
- npm deploy and npm test will not run successfully without AWS credentials. These can be accessed on the Auckland Uni wiki here
- Make sure that the credentials are located in
~/.aws/credentials
and take note of the profile for the credentials. Currentlysaml
is the default profile at the time of writing this. - If you wish to test with non-
dev
configurations you will also need to specify the--stage
option as eithersandbox
(sandbox account),dev
,test
(nonprod account) orprod
(prod account). - Passing in the aws credentials to the deploy and test commands can be done by adding arguments after a double dash to the run/test commands. This applies to any npm command.
- Deploying with the default dev stage and saml profile:
npm run deploy -- --aws-profile saml
- Running tests with non-prod stage environment variables.
npm run test -- --aws-profile saml --stage test
- Environmental variables can be set in
env/
which is used by serverless when deploying/testing lambda function.
- Environmental variables can be set in