Source & Config Files

Now, let's create configuration files.

SAM Configuration

Switch to function folder first.

$ cd $WORKSPACE/$FUNCTIONNAME/

Create template.yaml under this folder with the content below:

template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: A starter AWS Lambda function.
Parameters: 
    IdentityNameParameter: 
      Type: String
Resources:
  function-one:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: dist/index.handler
      Runtime: nodejs8.10
      CodeUri: .
      Description: A starter AWS Lambda function.
      MemorySize: 128
      Timeout: 3
      Environment:
        Variables:
          Stage: DEV

Node and TypeScript Configuration

Under the function folder we will create a few files.

TypeScript Configuration

Create tsconfig.json with the content below:

TypeScript Linting

Create tslint.json file with the content below:

Node Project Configuration

Edit package.json to make it look like below:

Visual Studio Code Configuration

Under workspace folder, create .vscode folder. Visual Studio Code configuration files are kept here.

Create launch.json with the content below:

Create settings.json with the content below:

Create tasks.json with the content below;

Create Lambda Function

We will create src folder first.

Create index.ts with the content below:

Create event.json with the content below:

Last updated

Was this helpful?