AWS Lambda function template with TypeScript for creating a simple API proxy.The example function simply retrieves data from an API endpoint and return it from API gateway.
- Serverless
- Webpack
- Typescript
- Jenkins
- Mocha
(1) Install all modules
npm i
It uses mocha for unit & integration tests. Istanbul for coverage.
# unit test
npm test
# integration test
npm run integration
- Jenkins
The project includes an example Jenkinsfile. Update according to your Jenkins setup for pipeline.
- From local machine
Use npm command and we can pass arguments as below. Alternatively, we can use sls deploy command.
# nonprod
sls deploy --stage nonprod # if you have serverless installed globally (npm i -g serverless)
npm run deploy -- --stage nonprod
# prod
sls deploy --stage prod
npm run deploy -- --stage prod
To remove, run the command below:
sls remove --stage nonprod
# or
npm run remove -- --stage nonprod
curl -H "x-api-key: <api key" -X GET https://url
We recommend to use AWS Lambda Power Tuning to optimise the memory size allocation (see details here).
Tools
Configuration & Miscellaneous Reference