UNPKG

function-stencil

Version:

A quickstart AWS Lambda function code generator. Downloads a template function code file, test harness file, sample SAM deffiniation and appropriate file structure.

88 lines (66 loc) • 1.83 kB
# Welcome to function-stencil šŸ‘‹ > A quickstart AWS Lambda function code generator. Downloads a template function code file, test harness file, sample SAM definition and appropriate file structure. ## Install ```sh npm install function-stencil ``` ## Usage ```sh function-stencil init ``` ### 1. Choose the function runtime ```sh ? What runtime do you need? (Use arrow keys) āÆ nodejs16.x nodejs14.x python3.9 java11 dotnet6 ``` ### 2. Provide a function name ```sh Whats the function name? MyFunctionName ``` ### 3. Choose a templating language snippet ```sh ? Choose one of the following templating languages for this runtime (Use arrow keys) āÆ sam terraform ``` ### 4. Function code and file system is generated ```sh MyFunctionName ā”— function ā”ƒ ┣ events ā”ƒ ā”ƒ ā”— event.json ā”ƒ ┣ app.js ā”ƒ ┣ env.json ā”ƒ ┣ harness.js ā”ƒ ā”— package.json ``` ### 4. AWS SAM snippet is generated, drop this into the resource block of your SAM template.yaml ```yaml MyFunctionName: Type: AWS::Serverless::Function Properties: CodeUri: MyFunctionName/function/ Handler: app.lambdaHandler Runtime: nodejs14.x Timeout: 3 ```` ## Testing Test your function locally by running `harness.js` from the *function* directory: ```sh > node harness.js { statusCode: 200, body: '{"message":"hello world"}' } localTest: 7.998ms ``` ## Contributing [Start here](https://github.com/bls20AWS/function-stencil/blob/main/CONTRIBUTING.md) ## Author šŸ‘¤ **Benjamin Smith** * Website: [https://github.com/bls20AWS/function-stencil](https://github.com/bls20AWS/function-stencil) * Twitter: [@benjamin\_l\_S](https://twitter.com/benjamin\_l\_S) * Github: [@bls20AWS](https://github.com/bls20AWS) ## Show your support Give a ā­ļø if this project helped you!